Skip to content

Commit

Permalink
+++
Browse files Browse the repository at this point in the history
  • Loading branch information
yalosev committed Nov 12, 2023
1 parent c03602c commit 204a8e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pkg/addon-operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 4 additions & 21 deletions pkg/module_manager/module_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -342,14 +322,16 @@ 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 {
// enabledModules is a subset of enabledModulesByConfig.
// 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
Expand All @@ -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()
}

Expand Down

0 comments on commit 204a8e2

Please sign in to comment.