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

Parameterize config watcher loop speed #1322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cmd/thin_entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Options struct {
ForceCNIVersion bool
SkipTLSVerify bool
SkipMultusConfWatch bool
WatchTimer time.Duration
}

const (
Expand Down Expand Up @@ -93,6 +94,7 @@ func (o *Options) addFlags() {
fs.StringVar(&o.AdditionalBinDir, "additional-bin-dir", "", "adds binDir option to configuration (used only with --multus-conf-file=auto)")
fs.BoolVar(&o.SkipTLSVerify, "skip-tls-verify", false, "skip TLS verify")
fs.BoolVar(&o.ForceCNIVersion, "force-cni-version", false, "force cni version to '--cni-version' (only for e2e-kind testing)")
fs.DurationVar(&o.WatchTimer, "multus-config-watch-timer", 1*time.Second, "how long to wait before reconciling multus config")
fs.MarkHidden("force-cni-version")
fs.MarkHidden("skip-tls-verify")
}
Expand Down Expand Up @@ -618,13 +620,16 @@ func main() {
defer cleanupMultusConf(&opt)
}

watcher := time.NewTicker(opt.WatchTimer)
defer watcher.Stop()

watchChanges := opt.CleanupConfigOnExit && opt.MultusConfFile == "auto" && !opt.SkipMultusConfWatch
if watchChanges {
fmt.Printf("Entering watch loop...\n")
masterConfigExists := true

outer:
for range time.Tick(1 * time.Second) {
for range watcher.C {
select {
case <-ctx.Done():
// signal received break from loop
Expand Down
4 changes: 4 additions & 0 deletions docs/how-to-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ master CNI configuration and kubeconfig. when such change detected, the script w

--skip-config-watch

The poll interval of the config changes watcher is configurable with `--multus-config-watch-timer=<duration>`. Please refer to the [time.Duration](https://pkg.go.dev/time#Duration) to configure the time interval. The following example watches the config change every 5 minutes.

Copy link
Member

Choose a reason for hiding this comment

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

Let's also provide a link to whatever appropriate go docs about what are valid values for "duration" here. Otherwise, lgtm

Copy link
Author

Choose a reason for hiding this comment

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

@dougbtv Thanks. I've updated the description with the go doc link for the duration. Please let me know if any suggestions.

--multus-config-watch-timer=5m

Additionally when using CRIO, you may wish to have the CNI config file that's used as the source for `--multus-conf-file=auto` renamed. This boolean option when set to true automatically renames the file with a `.old` suffix to the original filename.

--rename-conf-file=true
Expand Down