Skip to content

Commit

Permalink
refactor: log the requeue time out
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedwaleedmalik committed Aug 3, 2021
1 parent 0d2e70d commit 9e2b9a0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
const (
IngressMonitorControllerSecretConfigKey = "config.yaml"
IngressMonitorControllerSecretDefaultName = "imc-config"
requeueTimeEnvVariable = "REQUEUE_TIME"
defaultRequeueTime = 300
requeueTimeEnvVariable = "REQUEUE_TIME"
defaultRequeueTime = 300
)

var ReconciliationRequeueTime = getRequeueTime()
Expand Down Expand Up @@ -166,13 +166,15 @@ func ReadConfig(filePath string) Config {

// getRequeueTime returns the Requeue Time for the objects
// https://sdk.operatorframework.io/docs/building-operators/golang/tutorial/#reconcile-loop
func getRequeueTime() (time.Duration) {
func getRequeueTime() time.Duration {
output := defaultRequeueTime * time.Second
requeueTime, found := os.LookupEnv(requeueTimeEnvVariable)
if found && len(requeueTime) > 0 {
requeueTimeInt, err := strconv.ParseInt(requeueTime, 10, 64)
if err == nil {
return time.Duration(requeueTimeInt) * time.Second
if err == nil {
output = time.Duration(requeueTimeInt) * time.Second
}
}
return defaultRequeueTime * time.Second
}
log.Info("Reconciliation requeue time is set to %v", output)
return output
}

0 comments on commit 9e2b9a0

Please sign in to comment.