func (s *Syncer) enqueueVirtualCluster(obj interface{}) {
	_, ok := obj.(*v1alpha1.VirtualCluster)
	if !ok {
		tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
		if !ok {
			utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %+v", obj))
			return
		}
		_, ok = tombstone.Obj.(*v1alpha1.VirtualCluster)
		if !ok {
			utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a vc %+v", obj))
			return
		}
	}
	key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
	if err != nil {
		utilruntime.HandleError(err)
		return
	}
	s.queue.Add(key)
}
enqueue deleted and running object.
package syncer
import (
	"context"
	"fmt"
	"net/http"
	"os"
	"sync"
	"sync/atomic"
	"time"
	"github.com/prometheus/client_golang/prometheus/promhttp"
	v1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/types"
	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
	"k8s.io/apimachinery/pkg/util/wait"
	"k8s.io/client-go/informers"
	clientset "k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/cache"
	"k8s.io/client-go/tools/record"
	"k8s.io/client-go/util/workqueue"
	"k8s.io/klog"
	"k8s.io/apimachinery/pkg/util/sets"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/apis/tenancy/v1alpha1"
	vcclient "sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/client/clientset/versioned"
	vcinformers "sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/client/informers/externalversions/tenancy/v1alpha1"
	vclisters "sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/client/listers/tenancy/v1alpha1"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/apis/config"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/constants"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/conversion"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/manager"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/metrics"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/util/featuregate"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/util/cluster"
	utilconst "sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/util/constants"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/util/listener"
	mc "sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/util/mccontroller"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/util/plugin"
	"sigs.k8s.io/controller-runtime/pkg/client"
)
var (
	numHealthCluster   uint64
	numUnHealthCluster uint64
)
type Syncer struct {
	config            *config.SyncerConfiguration
	metaClient        clientset.Interface
	superClient       clientset.Interface
	recorder          record.EventRecorder
	controllerManager *manager.ControllerManager
	lister vclisters.VirtualClusterLister
	virtualClusterSynced cache.InformerSynced
	queue   workqueue.RateLimitingInterface
	workers int
	mu         sync.Mutex
	clusterSet map[string]mc.ClusterInterface
}
type virtualclusterGetter struct {
	lister vclisters.VirtualClusterLister
}
var _ mc.Getter = &virtualclusterGetter{}
func (v *virtualclusterGetter) GetObject(namespace, name string) (client.Object, error) {
	vc, err := v.lister.VirtualClusters(namespace).Get(name)
	if err != nil {
		return nil, err
	}
	return vc, nil
}
type Bootstrap interface {
	ListenAndServe(address, certFile, keyFile string)
	Run(<-chan struct{})
}
func New(
	config *config.SyncerConfiguration,
	virtualClusterClient vcclient.Interface,
	virtualClusterInformer vcinformers.VirtualClusterInformer,
	metaClusterClient clientset.Interface,
	superClusterClient clientset.Interface,
	superClusterInformers informers.SharedInformerFactory,
	recorder record.EventRecorder,
) (*Syncer, error) {
	syncer := &Syncer{
		config:      config,
		metaClient:  metaClusterClient,
		superClient: superClusterClient,
		recorder:    recorder,
		queue:       workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "virtual_cluster"),
		workers:     constants.UwsControllerWorkerLow,
		clusterSet:  make(map[string]mc.ClusterInterface),
	}
	virtualClusterInformer.Informer().AddEventHandler(
		cache.ResourceEventHandlerFuncs{
			AddFunc: syncer.enqueueVirtualCluster,
			UpdateFunc: func(oldObj, newObj interface{}) {
				newVC := newObj.(*v1alpha1.VirtualCluster)
				oldVC := oldObj.(*v1alpha1.VirtualCluster)
				if newVC.ResourceVersion == oldVC.ResourceVersion {
					return
				}
				syncer.enqueueVirtualCluster(newObj)
			},
			DeleteFunc: syncer.enqueueVirtualCluster,
		},
	)
	syncer.lister = virtualClusterInformer.Lister()
	syncer.virtualClusterSynced = virtualClusterInformer.Informer().HasSynced
	multiClusterControllerManager := manager.New()
	syncer.controllerManager = multiClusterControllerManager
	plugins := LoadPlugins(config)
	initContext := &plugin.InitContext{
		Context:    context.Background(),
		Config:     config,
		Client:     superClusterClient,
		Informer:   superClusterInformers,
		VCClient:   virtualClusterClient,
		VCInformer: virtualClusterInformer,
	}
	for _, p := range plugins {
		klog.Infof("loading plugin %q...", p.ID)
		result := p.Init(initContext)
		instance, err := result.Instance()
		if err != nil {
			klog.Errorf("failed to load plugin %q", p.ID)
			return nil, err
		}
		s, ok := instance.(manager.ResourceSyncer)
		if ok {
			multiClusterControllerManager.AddResourceSyncer(s)
		} else {
			klog.Warningf("unrecognized plugin %q", p.ID)
		}
	}
	return syncer, nil
}
func LoadPlugins(config *config.SyncerConfiguration) []*plugin.Registration {
	allPlugin := plugin.SyncerResourceRegister.List()
	var enablePlugin []*plugin.Registration
	extraSets := sets.NewString(config.ExtraSyncingResources...)
	for i, r := range allPlugin {
		if !r.Disable || extraSets.Has(r.ID) {
			enablePlugin = append(enablePlugin, allPlugin[i])
		}
	}
	return enablePlugin
}