@@ -50,6 +50,15 @@ const (
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
5252 OpConfigReconcileIntervalPercentage = "reconcileIntervalIncreasePercentage"
53+
54+ // OpConfigReconcileIntervalFailureMaximum default max reconcile interval for repeated failures
55+ OpConfigReconcileIntervalFailureMaximum = "reconcileIntervalFailureMaximum"
56+
57+ // OpConfigReconcileIntervalSuccessMaximum default max reconcile interval for repeated successful reconciled and application ready status
58+ OpConfigReconcileIntervalSuccessMaximum = "reconcileIntervalSuccessMaximum"
59+
60+ // OpConfigShowReconcileInterval default whether reconcile interval will be visible in the instance's status field
61+ OpConfigShowReconcileInterval = "showReconcileInterval"
5362)
5463
5564// Config stores operator configuration
@@ -102,21 +111,34 @@ func LoadFromConfig(oc *sync.Map, key string) string {
102111func CheckValidValue (oc * sync.Map , key string , OperatorName string ) error {
103112 value := LoadFromConfig (oc , key )
104113
105- intValue , err := strconv .Atoi (value )
114+ floatValue , err := strconv .ParseFloat (value , 64 )
106115 if err != nil {
107116 SetConfigMapDefaultValue (oc , key )
108117 return errors .New (key + " in ConfigMap: " + OperatorName + " has an invalid syntax, error: " + err .Error ())
109- } else if key == OpConfigReconcileIntervalMinimum && intValue <= 0 {
118+ } else if key == OpConfigReconcileIntervalMinimum && floatValue <= 0 {
110119 SetConfigMapDefaultValue (oc , key )
111120 return errors .New (key + " in ConfigMap: " + OperatorName + " is set to " + value + ". It must be greater than 0." )
112- } else if key == OpConfigReconcileIntervalPercentage && intValue < 0 {
121+ } else if key == OpConfigReconcileIntervalPercentage && floatValue < 0 {
113122 SetConfigMapDefaultValue (oc , key )
114123 return errors .New (key + " in ConfigMap: " + OperatorName + " is set to " + value + ". It must be greater than or equal to 0." )
124+ } else if key == OpConfigReconcileIntervalFailureMaximum && floatValue <= 0 {
125+ SetConfigMapDefaultValue (oc , key )
126+ return errors .New (key + " in ConfigMap: " + OperatorName + " is set to " + value + ". It must be greater than 0." )
127+ } else if key == OpConfigReconcileIntervalSuccessMaximum && floatValue <= 0 {
128+ SetConfigMapDefaultValue (oc , key )
129+ return errors .New (key + " in ConfigMap: " + OperatorName + " is set to " + value + ". It must be greater than 0." )
115130 }
116-
117131 return nil
118132}
119133
134+ func UpdateReconcileIntervalPercentage (oc * sync.Map , OperatorName string ) {
135+ intervalIncreasePercentage , _ := strconv .ParseFloat (LoadFromConfig (oc , OpConfigReconcileIntervalPercentage ), 64 )
136+ if intervalIncreasePercentage == 100 {
137+ intervalIncreasePercentageStr := strconv .FormatFloat (50 , 'f' , - 1 , 64 )
138+ oc .Store (OpConfigReconcileIntervalPercentage , intervalIncreasePercentageStr )
139+ }
140+ }
141+
120142// SetConfigMapDefaultValue sets default value for specified key
121143func SetConfigMapDefaultValue (oc * sync.Map , key string ) {
122144 cm := DefaultOpConfig ()
@@ -159,6 +181,9 @@ func DefaultOpConfig() *sync.Map {
159181 cfg .Store (OpConfigCMCertDuration , "2160h" )
160182 cfg .Store (OpConfigLogLevel , logLevelInfo )
161183 cfg .Store (OpConfigReconcileIntervalMinimum , "5" )
162- cfg .Store (OpConfigReconcileIntervalPercentage , "100" )
184+ cfg .Store (OpConfigReconcileIntervalPercentage , "50" )
185+ cfg .Store (OpConfigReconcileIntervalFailureMaximum , "240" )
186+ cfg .Store (OpConfigReconcileIntervalSuccessMaximum , "120" )
187+ cfg .Store (OpConfigShowReconcileInterval , "false" )
163188 return cfg
164189}
0 commit comments