Skip to content

Commit

Permalink
reconciler: only read from flatfile if config is not present
Browse files Browse the repository at this point in the history
This change will allow us to unit test the configuration updates without
having to create the CNI configuration files (they're unrelated to this
unit).

Signed-off-by: Miguel Duarte Barroso <[email protected]>
  • Loading branch information
maiqueb committed Dec 22, 2023
1 parent f67b5ce commit da358de
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/controlloop/controlloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,14 @@ func newEventRecorder(broadcaster record.EventBroadcaster) record.EventRecorder
}

func determineCronExpression() string {
flatipam, _, err := config.GetFlatIPAM(true, &types.IPAMConfig{}, "")
if err != nil {
_ = logging.Errorf("could not get flatipam config: %v", err)
os.Exit(couldNotGetFlatIPAM)
}

// We read the expression from a file if present, otherwise we use ReconcilerCronExpression
fileContents, err := os.ReadFile(reconcilerCronConfiguration)
if err != nil {
flatipam, _, err := config.GetFlatIPAM(true, &types.IPAMConfig{}, "")
if err != nil {
_ = logging.Errorf("could not get flatipam config: %v", err)
os.Exit(couldNotGetFlatIPAM)
}
_ = logging.Errorf("could not read file: %v, using expression from flatfile: %v", err, flatipam.IPAM.ReconcilerCronExpression)
return flatipam.IPAM.ReconcilerCronExpression
}
Expand Down

0 comments on commit da358de

Please sign in to comment.