Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigMap informer should only watch --asm-configmap-based-config-nam… #1780

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/cmconfig/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ func (c *ConfigMapConfigController) DisableASM() {

// SetASMReadyTrue update the ASMReady to True.
func (c *ConfigMapConfigController) SetASMReadyTrue() {
klog.V(0).Info("SetASMReadyTrue")
c.updateASMReady(trueValue)
}

// SetASMReadyFalse update the ASMReady to False.
func (c *ConfigMapConfigController) SetASMReadyFalse() {
klog.V(0).Info("SetASMReadyFalse")
c.updateASMReady(falseValue)
}

Expand Down Expand Up @@ -125,10 +127,15 @@ func (c *ConfigMapConfigController) RegisterInformer(configMapInformer cache.Sha
}

func (c *ConfigMapConfigController) processItem(obj interface{}, cancel func()) {
klog.V(4).Infof("ConfigMapConfigController.processItem()")

configMap, ok := obj.(*v1.ConfigMap)
if !ok {
klog.Errorf("ConfigMapConfigController: failed to convert informer object to ConfigMap.")
}

klog.V(3).Infof("ConfigMapConfigController.processItem '%s.%s'", configMap.Namespace, configMap.Name)

if configMap.Namespace != c.configMapNamespace || configMap.Name != c.configMapName {
return
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/dynamic/dynamicinformer"
informers "k8s.io/client-go/informers"
informerv1 "k8s.io/client-go/informers/core/v1"
discoveryinformer "k8s.io/client-go/informers/discovery/v1"
informernetworking "k8s.io/client-go/informers/networking/v1"
Expand Down Expand Up @@ -224,8 +225,10 @@ func (ctx *ControllerContext) Init() {
klog.V(2).Infof("Controller Context initializing with %+v", ctx.ControllerContextConfig)
// Initialize controller context internals based on ASMConfigMap
if ctx.EnableASMConfigMap {
configMapInformer := informerv1.NewConfigMapInformer(ctx.KubeClient, ctx.Namespace, ctx.ResyncPeriod, utils.NewNamespaceIndexer())
ctx.ConfigMapInformer = configMapInformer
klog.Infof("ASMConfigMap is enabled")

informerFactory := informers.NewSharedInformerFactoryWithOptions(ctx.KubeClient, ctx.ResyncPeriod, informers.WithNamespace(ctx.ASMConfigMapNamespace))
ctx.ConfigMapInformer = informerFactory.Core().V1().ConfigMaps().Informer()
ctx.ASMConfigController = cmconfig.NewConfigMapConfigController(ctx.KubeClient, ctx.Recorder(ctx.ASMConfigMapNamespace), ctx.ASMConfigMapNamespace, ctx.ASMConfigMapName)

cmConfig := ctx.ASMConfigController.GetConfig()
Expand All @@ -235,7 +238,6 @@ func (ctx *ControllerContext) Init() {
ctx.ASMConfigController.SetASMReadyFalse()
}
}

}

func (ctx *ControllerContext) initEnableASM() {
Expand All @@ -247,6 +249,8 @@ func (ctx *ControllerContext) initEnableASM() {
destinationRuleCRDName = "destinationrules.networking.istio.io"
)

klog.V(0).Infof("ASM mode is enabled from ConfigMap")

apiextensionClient, err := apiextensionsclientset.NewForConfig(ctx.KubeConfig)
if err != nil {
msg := fmt.Sprintf("Failed to create ApiextensionClient for DestinationRule, disabling ASM Mode, error: %s", err)
Expand Down