in pkg/k8scontext/context.go [171:255]
func (c *Context) Run(stopChannel chan struct{}, omitCRDs bool, envVariables environment.EnvVariables) error {
klog.V(1).Infoln("k8s context run started")
var hasSynced []cache.InformerSynced
if c.informers == nil {
e := controllererrors.NewError(
controllererrors.ErrorInformersNotInitialized,
"informers are not initialized",
)
c.MetricStore.IncErrorCount(e.Code)
return e
}
crds := map[cache.SharedInformer]interface{}{
c.informers.AzureIngressProhibitedTarget: nil,
c.informers.IstioGateway: nil,
c.informers.IstioVirtualService: nil,
c.informers.MultiClusterService: nil,
c.informers.MultiClusterIngress: nil,
c.informers.AzureApplicationGatewayRewrite: nil,
// c.informers.AzureApplicationGatewayBackendPool: nil,
// c.informers.AzureApplicationGatewayInstanceUpdateStatus: nil,
}
sharedInformers := []cache.SharedInformer{
c.informers.Endpoints,
c.informers.Pods,
c.informers.Service,
c.informers.Secret,
c.informers.Ingress,
c.informers.AzureApplicationGatewayRewrite,
//TODO: enabled by ccp feature flag
// c.informers.AzureApplicationGatewayBackendPool,
// c.informers.AzureApplicationGatewayInstanceUpdateStatus,
}
if IsNetworkingV1PackageSupported {
sharedInformers = append(sharedInformers, c.informers.IngressClass)
}
// For AGIC to watch for these CRDs the EnableBrownfieldDeploymentVarName env variable must be set to true
if envVariables.EnableBrownfieldDeployment {
sharedInformers = append(sharedInformers, c.informers.AzureIngressProhibitedTarget)
}
// For AGIC to watch for these CRDs the MultiClusterMode env variable must be set to true
if envVariables.MultiClusterMode {
sharedInformers = []cache.SharedInformer{} //only need to monitor 3 resources
sharedInformers = append(sharedInformers, c.informers.MultiClusterIngress)
sharedInformers = append(sharedInformers, c.informers.MultiClusterService)
}
if envVariables.EnableIstioIntegration {
sharedInformers = append(sharedInformers, c.informers.IstioGateway, c.informers.IstioVirtualService)
}
for _, informer := range sharedInformers {
go informer.Run(stopChannel)
// NOTE: Delyan could not figure out how to make informer.HasSynced == true for the CRDs in unit tests
// so until we do that - we omit WaitForCacheSync for CRDs in unit testing
if _, isCRD := crds[informer]; isCRD {
continue
}
hasSynced = append(hasSynced, informer.HasSynced)
}
klog.V(1).Infoln("Waiting for initial cache sync")
if !cache.WaitForCacheSync(stopChannel, hasSynced...) {
e := controllererrors.NewError(
controllererrors.ErrorFailedInitialCacheSync,
"failed initial sync of resources required for ingress",
)
c.MetricStore.IncErrorCount(e.Code)
return e
}
// Closing the cacheSynced channel signals to the rest of the system that... caches have been synced.
close(c.CacheSynced)
klog.V(1).Infoln("Initial cache sync done")
klog.V(1).Infoln("k8s context run finished")
return nil
}