From 204a8e25ef4d6bd12c506cae5cfd76adac32b958 Mon Sep 17 00:00:00 2001 From: Yuriy Losev Date: Sun, 12 Nov 2023 22:23:17 +0400 Subject: [PATCH] +++ --- pkg/addon-operator/operator.go | 4 ++-- pkg/module_manager/module_manager.go | 25 ++++--------------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/pkg/addon-operator/operator.go b/pkg/addon-operator/operator.go index 4a17e4ae1..7a12541c9 100644 --- a/pkg/addon-operator/operator.go +++ b/pkg/addon-operator/operator.go @@ -221,9 +221,9 @@ func (op *AddonOperator) InitModuleManager() error { return fmt.Errorf("init module manager: %s", err) } - // Load existing config values from ConfigMap. + // Load existing config values from KubeConfigManager. // Also, it is possible to override initial KubeConfig to give global hooks a chance - // to handle the ConfigMap content later. + // to handle the KubeConfigManager content later. if op.InitialKubeConfig == nil { op.KubeConfigManager.SafeReadConfig(func(config *config.KubeConfig) { _, err = op.ModuleManager.HandleNewKubeConfig(config) diff --git a/pkg/module_manager/module_manager.go b/pkg/module_manager/module_manager.go index 8bbbbc0f5..d10851eb1 100644 --- a/pkg/module_manager/module_manager.go +++ b/pkg/module_manager/module_manager.go @@ -303,32 +303,12 @@ func (mm *ModuleManager) HandleNewKubeConfig(kubeConfig *config.KubeConfig) (*Mo return &ModulesState{}, validationErrors.ErrorOrNil() } - //// Check if values in new KubeConfig are valid. Return error to prevent poisoning caches with invalid values. - //err = mm.validateKubeConfig(kubeConfig, newEnabledByConfig) - //if err != nil { - // return nil, fmt.Errorf("config not valid: %v", err) - //} - // Detect changes in global section. hasGlobalChange := false if kubeConfig.Global != nil && globalModule.ConfigValuesHaveChanges() { hasGlobalChange = true } - //newGlobalValues := mm.kubeGlobalConfigValues - //if (kubeConfig == nil || kubeConfig.Global == nil) && mm.kubeGlobalConfigValues.HasGlobal() { - // hasGlobalChange = true - // newGlobalValues = make(utils.Values) - //} - //if kubeConfig != nil && kubeConfig.Global != nil { - // globalChecksum := mm.kubeGlobalConfigValues.Checksum() - // - // if kubeConfig.Global.Checksum != globalChecksum { - // hasGlobalChange = true - // } - // newGlobalValues = kubeConfig.Global.GetValues() - //} - // Full reload if enabled flags are changed. isEnabledChanged := false for _, moduleName := range mm.modules.NamesInOrder() { @@ -342,6 +322,7 @@ func (mm *ModuleManager) HandleNewKubeConfig(kubeConfig *config.KubeConfig) (*Mo } } + fmt.Println("ENABLED", mm.enabledModules) // Detect changed module sections for enabled modules. modulesChanged := make([]string, 0) if !isEnabledChanged { @@ -349,7 +330,8 @@ func (mm *ModuleManager) HandleNewKubeConfig(kubeConfig *config.KubeConfig) (*Mo // Module can be enabled by config, but disabled with enabled script. // So check only sections for effectively enabled modules. for _, moduleName := range mm.enabledModules { - mod := mm.GetModule(moduleName).GetBaseModule() + mod := mm.GetModule(moduleName) + fmt.Println("MODULE XXXX", moduleName) //modValues, hasConfigValues := mm.kubeModulesConfigValues[moduleName] // New module state from ConfigMap. //hasNewKubeConfig := false @@ -360,6 +342,7 @@ func (mm *ModuleManager) HandleNewKubeConfig(kubeConfig *config.KubeConfig) (*Mo if mod.ConfigValuesHaveChanges() { modulesChanged = append(modulesChanged, moduleName) + fmt.Println("COMMIT MODULE", moduleName) mod.CommitConfigValuesChange() }