Skip to content

Commit 762c4a3

Browse files
authored
Rename reconcileIntervalSeconds to reconcileIntervalMinimum (#673)
Signed-off-by: Leo Christy Jesuraj <[email protected]>
1 parent 9f84d9a commit 762c4a3

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

common/config.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ const (
4444
// zapcore.Level is defined as int8, so this logs everything
4545
zLevelDebugMax zapcore.Level = -127
4646

47-
// OpConfigReconcileIntervalSeconds default reconciliation interval in seconds
48-
OpConfigReconcileIntervalSeconds = "reconcileIntervalSeconds"
47+
// OpConfigReconcileIntervalMinimum default reconciliation interval in seconds
48+
OpConfigReconcileIntervalMinimum = "reconcileIntervalMinimum"
4949

5050
// OpConfigReconcileIntervalPercentage default reconciliation interval increase, represented as a percentage (100 equaling to 100%)
5151
// 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 {
106106
if err != nil {
107107
SetConfigMapDefaultValue(oc, key)
108108
return errors.New(key + " in ConfigMap: " + OperatorName + " has an invalid syntax, error: " + err.Error())
109-
} else if key == OpConfigReconcileIntervalSeconds && intValue <= 0 {
109+
} else if key == OpConfigReconcileIntervalMinimum && intValue <= 0 {
110110
SetConfigMapDefaultValue(oc, key)
111111
return errors.New(key + " in ConfigMap: " + OperatorName + " is set to " + value + ". It must be greater than 0.")
112112
} else if key == OpConfigReconcileIntervalPercentage && intValue < 0 {
@@ -158,7 +158,7 @@ func DefaultOpConfig() *sync.Map {
158158
cfg.Store(OpConfigCMCADuration, "8766h")
159159
cfg.Store(OpConfigCMCertDuration, "2160h")
160160
cfg.Store(OpConfigLogLevel, logLevelInfo)
161-
cfg.Store(OpConfigReconcileIntervalSeconds, "5")
161+
cfg.Store(OpConfigReconcileIntervalMinimum, "5")
162162
cfg.Store(OpConfigReconcileIntervalPercentage, "100")
163163
return cfg
164164
}

internal/controller/runtimecomponent_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (r *RuntimeComponentReconciler) Reconcile(ctx context.Context, req ctrl.Req
124124
return reconcile.Result{}, err
125125
}
126126

127-
if err = common.CheckValidValue(common.Config, common.OpConfigReconcileIntervalSeconds, OperatorName); err != nil {
127+
if err = common.CheckValidValue(common.Config, common.OpConfigReconcileIntervalMinimum, OperatorName); err != nil {
128128
return r.ManageError(err, common.StatusConditionTypeReconciled, instance)
129129
}
130130

utils/reconciler.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func addStatusWarnings(ba common.BaseComponent) {
198198
}
199199

200200
func getBaseReconcileInterval(s common.BaseComponentStatus) int32 {
201-
baseIntervalInt, _ := strconv.Atoi(common.LoadFromConfig(common.Config, common.OpConfigReconcileIntervalSeconds))
201+
baseIntervalInt, _ := strconv.Atoi(common.LoadFromConfig(common.Config, common.OpConfigReconcileIntervalMinimum))
202202
baseInterval := int32(baseIntervalInt)
203203
s.SetReconcileInterval(&baseInterval)
204204

@@ -213,7 +213,7 @@ func resetReconcileInterval(newCondition common.StatusCondition, s common.BaseCo
213213
return time.Duration(baseInterval) * time.Second
214214
}
215215

216-
// Precondition: Operator config values for common.OpConfigReconcileIntervalSeconds and common.OpConfigReconcileIntervalPercentage must be integers
216+
// Precondition: Operator config values for common.OpConfigReconcileIntervalMinimum and common.OpConfigReconcileIntervalPercentage must be integers
217217
func updateReconcileInterval(maxSeconds int, oldCondition common.StatusCondition, newCondition common.StatusCondition, s common.BaseComponentStatus) time.Duration {
218218
var oldReconcileInterval int32
219219

@@ -238,7 +238,7 @@ func updateReconcileInterval(maxSeconds int, oldCondition common.StatusCondition
238238
exp := float64(newCount / 2)
239239
increase := math.Pow(1+(intervalIncreasePercentage/100), exp)
240240

241-
baseInterval, _ := strconv.ParseFloat(common.LoadFromConfig(common.Config, common.OpConfigReconcileIntervalSeconds), 64)
241+
baseInterval, _ := strconv.ParseFloat(common.LoadFromConfig(common.Config, common.OpConfigReconcileIntervalMinimum), 64)
242242
newInterval := int32(baseInterval * increase)
243243

244244
// Only increase to the maximum interval

0 commit comments

Comments
 (0)