// NewMizarArktosNetworkController starts arktos network controller for mizar
NewMizarArktosNetworkController starts arktos network controller for mizar
// NewMizarArktosNetworkController starts arktos network controller for mizar
func NewMizarArktosNetworkController(dynamicClient dynamic.Interface, netClientset *arktos.Clientset, kubeClientset *kubernetes.Clientset,
	networkInformer arktosinformer.NetworkInformer, grpcHost string, grpcAdaptor IGrpcAdaptor, vpcRangeStart int, vpcRangeEnd int) *MizarArktosNetworkController {
	utilruntime.Must(arktoscheme.AddToScheme(scheme.Scheme))
	eventBroadcaster := record.NewBroadcaster()
	eventBroadcaster.StartLogging(klog.Infof)
	eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClientset.CoreV1().EventsWithMultiTenancy(metav1.NamespaceAll, metav1.TenantAll)})
	c := &MizarArktosNetworkController{
		dynamicClient:       dynamicClient,
		netClientset:        netClientset,
		networkLister:       networkInformer.Lister(),
		networkListerSynced: networkInformer.Informer().HasSynced,
		queue:               workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
		recorder:            eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: "mizar-arktos-network-controller"}),
		grpcHost:            grpcHost,
		grpcAdaptor:         grpcAdaptor,
	}
	networkInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: c.createNetwork,
	})
	c.networkLister = networkInformer.Lister()
	c.networkListerSynced = networkInformer.Informer().HasSynced
	c.syncHandler = c.syncNetwork
	if utilfeature.DefaultFeatureGate.Enabled(features.MizarVPCRangeNoOverlap) {
		klog.Infof("feature MizarVPCRangeNoOverlap enabled")
		if !isValidVPCRange(vpcRangeStart, vpcRangeEnd) {
			klog.Fatalf("Invalid VPC range [%d, %d]", vpcRangeStart, vpcRangeEnd)
		} else {
			klog.Infof("VPC range [%d, %d]", vpcRangeStart, vpcRangeEnd)
		}
		c.vpcCache = &vpcUsedCache{
			vpcRangeStart: vpcRangeStart,
			vpcRangeEnd:   vpcRangeEnd,
			vpcUsedCache:  make(map[int]bool),
		}
		err := c.populateCache()
		if err != nil {
			klog.Fatalf("Unable to get used VPC range from registry. Error %v", err)
		}
	}
	return c
}
func NewMizarArktosNetworkController ( dynamicClient dynamic . Interface , netClientset * arktos . Clientset , kubeClientset * kubernetes . Clientset , networkInformer arktosinformer . NetworkInformer , grpcHost string , grpcAdaptor IGrpcAdaptor , vpcRangeStart int , vpcRangeEnd int ) * MizarArktosNetworkController { utilruntime . Must ( arktoscheme . AddToScheme ( scheme . Scheme ) ) eventBroadcaster := record . NewBroadcaster ( ) eventBroadcaster . StartLogging ( klog . Infof ) eventBroadcaster . StartRecordingToSink ( & v1core . EventSinkImpl { Interface : kubeClientset . CoreV1 ( ) . EventsWithMultiTenancy ( metav1 . NamespaceAll , metav1 . TenantAll ) } ) c := & MizarArktosNetworkController { dynamicClient : dynamicClient , netClientset : netClientset , networkLister : networkInformer . Lister ( ) , networkListerSynced : networkInformer . Informer ( ) . HasSynced , queue : workqueue . NewRateLimitingQueue ( workqueue . DefaultControllerRateLimiter ( ) ) , recorder : eventBroadcaster . NewRecorder ( scheme . Scheme , corev1 . EventSource { Component : " " } ) , grpcHost : grpcHost , grpcAdaptor : grpcAdaptor , } networkInformer . Informer ( ) . AddEventHandler ( cache . ResourceEventHandlerFuncs { AddFunc : c . createNetwork , } ) c . networkLister = networkInformer . Lister ( ) c . networkListerSynced = networkInformer . Informer ( ) . HasSynced c . syncHandler = c . syncNetwork if utilfeature . DefaultFeatureGate . Enabled ( features . MizarVPCRangeNoOverlap ) { klog . Infof ( " " ) if ! isValidVPCRange ( vpcRangeStart , vpcRangeEnd ) { klog . Fatalf ( " " , vpcRangeStart , vpcRangeEnd ) } else { klog . Infof ( " " , vpcRangeStart , vpcRangeEnd ) } c . vpcCache = & vpcUsedCache { vpcRangeStart : vpcRangeStart , vpcRangeEnd : vpcRangeEnd , vpcUsedCache : make ( map [ int ] bool ) , } err := c . populateCache ( ) if err != nil { klog . Fatalf ( " " , err ) } } return c }
NewMizarArktosNetworkController starts arktos network controller for mizar
NewMizarArktosNetworkController starts arktos network controller for mizar