Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable cron schedule for reconciler #398

Merged

Conversation

maiqueb
Copy link
Collaborator

@maiqueb maiqueb commented Dec 20, 2023

What this PR does / why we need it:
This PR builds on top of #392 (which adds a config map from where the reconciler scheduler can be configured via a config map) to react to updates of said configuration.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer (optional):
Tested locally.

nicklesimba and others added 3 commits December 20, 2023 16:42
Signed-off-by: nicklesimba <simha.nikhil@gmail.com>
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
go syncConfiguration(watcher, s, job, errorChan)
if err := watcher.Add(reconcilerCronConfiguration); err != nil {
_ = logging.Errorf("error adding watcher to config %q: %v", reconcilerCronConfiguration, err)
os.Exit(1234)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unique, but, they're non zero. :approved-stamp:

}
defer watcher.Close()

go syncConfiguration(watcher, s, job, errorChan)
if err := watcher.Add(reconcilerCronConfiguration); err != nil {
_ = logging.Errorf("error adding watcher to config %q: %v", reconcilerCronConfiguration, err)
os.Exit(1234)
os.Exit(fileWatcherAddWatcherError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it :) ok now I see what's up. thanks, perfect

Copy link
Member

@dougbtv dougbtv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the fixes, naming updates, and improvements. This looks like it's working well in my lab... output from starting and changing the cron expression...

[fedora@labkube-master-1 whereabouts]$ kubectl logs -f -n kube-system whereabouts-trz62
Done configuring CNI.  Sleep=false
2023-12-20T17:00:22Z [debug] Filtering pods with filter key 'spec.nodeName' and filter value 'labkube-master-1'
2023-12-20T17:00:22Z [verbose] pod controller created
2023-12-20T17:00:22Z [verbose] Starting informer factories ...
2023-12-20T17:00:22Z [verbose] Informer factories started
2023-12-20T17:00:22Z [verbose] starting network controller
2023-12-20T17:00:23Z [verbose] using expression: 30 4 * * *
2023-12-20T17:00:23Z [verbose] started cron with job ID: "02dec27b-53d6-4c7c-a9f6-faee98afbb75"
2023-12-20T17:02:37Z [verbose] using expression: */2 * * * *
2023-12-20T17:02:37Z [verbose] configuration updated to file "/cron-schedule/config". New cron expression: */2 * * * *
2023-12-20T17:02:37Z [verbose] successfully updated CRON configuration id "02dec27b-53d6-4c7c-a9f6-faee98afbb75" - new cron expression: */2 * * * *
2023-12-20T17:02:37Z [verbose] using expression: */2 * * * *
2023-12-20T17:02:37Z [verbose] configuration updated to file "/cron-schedule/config". New cron expression: */2 * * * *
2023-12-20T17:02:37Z [verbose] successfully updated CRON configuration id "02dec27b-53d6-4c7c-a9f6-faee98afbb75" - new cron expression: */2 * * * *
2023-12-20T17:04:00Z [verbose] starting reconciler run
2023-12-20T17:04:00Z [debug] NewReconcileLooper - inferred connection data
2023-12-20T17:04:00Z [debug] listing IP pools
2023-12-20T17:04:00Z [debug] no IP addresses to cleanup
2023-12-20T17:04:00Z [verbose] reconciler success

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 <mdbarroso@redhat.com>
Move everything related to watching / updating the configuration to a
separate pkg. That makes the code easier to follow, and allows us to
properly unit test watching the configuration.

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
This allows us to use cron expressions with seconds in the tests, thus
allowing the test run to finish a lot quicker.

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
@maiqueb
Copy link
Collaborator Author

maiqueb commented Dec 22, 2023

@dougbtv I've added a unit test that shows this working.

I think that's enough ...

I'm OK with merging. Let's talk about it in 2024.

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
@dougbtv dougbtv merged commit dc0888c into k8snetworkplumbingwg:master Jan 2, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants