diff --git a/common/config.go b/common/config.go index ff082257..b5b55837 100644 --- a/common/config.go +++ b/common/config.go @@ -44,8 +44,8 @@ const ( // zapcore.Level is defined as int8, so this logs everything zLevelDebugMax zapcore.Level = -127 - // OpConfigReconcileIntervalSeconds default reconciliation interval in seconds - OpConfigReconcileIntervalSeconds = "reconcileIntervalSeconds" + // OpConfigReconcileIntervalMinimum default reconciliation interval in seconds + OpConfigReconcileIntervalMinimum = "reconcileIntervalMinimum" // OpConfigReconcileIntervalPercentage default reconciliation interval increase, represented as a percentage (100 equaling to 100%) // When the reconciliation interval needs to increase, it will increase by the given percentage @@ -106,7 +106,7 @@ func CheckValidValue(oc *sync.Map, key string, OperatorName string) error { if err != nil { SetConfigMapDefaultValue(oc, key) return errors.New(key + " in ConfigMap: " + OperatorName + " has an invalid syntax, error: " + err.Error()) - } else if key == OpConfigReconcileIntervalSeconds && intValue <= 0 { + } else if key == OpConfigReconcileIntervalMinimum && intValue <= 0 { SetConfigMapDefaultValue(oc, key) return errors.New(key + " in ConfigMap: " + OperatorName + " is set to " + value + ". It must be greater than 0.") } else if key == OpConfigReconcileIntervalPercentage && intValue < 0 { @@ -158,7 +158,7 @@ func DefaultOpConfig() *sync.Map { cfg.Store(OpConfigCMCADuration, "8766h") cfg.Store(OpConfigCMCertDuration, "2160h") cfg.Store(OpConfigLogLevel, logLevelInfo) - cfg.Store(OpConfigReconcileIntervalSeconds, "5") + cfg.Store(OpConfigReconcileIntervalMinimum, "5") cfg.Store(OpConfigReconcileIntervalPercentage, "100") return cfg } diff --git a/internal/controller/runtimecomponent_controller.go b/internal/controller/runtimecomponent_controller.go index 276c87d7..fb369d50 100644 --- a/internal/controller/runtimecomponent_controller.go +++ b/internal/controller/runtimecomponent_controller.go @@ -124,7 +124,7 @@ func (r *RuntimeComponentReconciler) Reconcile(ctx context.Context, req ctrl.Req return reconcile.Result{}, err } - if err = common.CheckValidValue(common.Config, common.OpConfigReconcileIntervalSeconds, OperatorName); err != nil { + if err = common.CheckValidValue(common.Config, common.OpConfigReconcileIntervalMinimum, OperatorName); err != nil { return r.ManageError(err, common.StatusConditionTypeReconciled, instance) } diff --git a/utils/reconciler.go b/utils/reconciler.go index 1a2c2002..16374cd9 100644 --- a/utils/reconciler.go +++ b/utils/reconciler.go @@ -198,7 +198,7 @@ func addStatusWarnings(ba common.BaseComponent) { } func getBaseReconcileInterval(s common.BaseComponentStatus) int32 { - baseIntervalInt, _ := strconv.Atoi(common.LoadFromConfig(common.Config, common.OpConfigReconcileIntervalSeconds)) + baseIntervalInt, _ := strconv.Atoi(common.LoadFromConfig(common.Config, common.OpConfigReconcileIntervalMinimum)) baseInterval := int32(baseIntervalInt) s.SetReconcileInterval(&baseInterval) @@ -213,7 +213,7 @@ func resetReconcileInterval(newCondition common.StatusCondition, s common.BaseCo return time.Duration(baseInterval) * time.Second } -// Precondition: Operator config values for common.OpConfigReconcileIntervalSeconds and common.OpConfigReconcileIntervalPercentage must be integers +// Precondition: Operator config values for common.OpConfigReconcileIntervalMinimum and common.OpConfigReconcileIntervalPercentage must be integers func updateReconcileInterval(maxSeconds int, oldCondition common.StatusCondition, newCondition common.StatusCondition, s common.BaseComponentStatus) time.Duration { var oldReconcileInterval int32 @@ -238,7 +238,7 @@ func updateReconcileInterval(maxSeconds int, oldCondition common.StatusCondition exp := float64(newCount / 2) increase := math.Pow(1+(intervalIncreasePercentage/100), exp) - baseInterval, _ := strconv.ParseFloat(common.LoadFromConfig(common.Config, common.OpConfigReconcileIntervalSeconds), 64) + baseInterval, _ := strconv.ParseFloat(common.LoadFromConfig(common.Config, common.OpConfigReconcileIntervalMinimum), 64) newInterval := int32(baseInterval * increase) // Only increase to the maximum interval