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 #1232

Closed
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
8 changes: 6 additions & 2 deletions cmd/thin_entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Options struct {
AdditionalBinDir string
ForceCNIVersion bool
SkipTLSVerify bool
WatchTimer time.Duration
}

const (
Expand Down Expand Up @@ -90,6 +91,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 @@ -594,9 +596,12 @@ func main() {
fmt.Printf("multus config file is created.\n")
}

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

if opt.CleanupConfigOnExit && opt.MultusConfFile == "auto" {
fmt.Printf("Entering watch loop...\n")
for {
for range watcher.C {
// Check kubeconfig and update if different (i.e. service account updated)
caHash, saTokenHash, err = opt.createKubeConfig(caHash, saTokenHash)
if err != nil {
Expand Down Expand Up @@ -625,7 +630,6 @@ func main() {
fmt.Fprintf(os.Stderr, "failed to create multus config: %v\n", err)
return
}
time.Sleep(1 * time.Second)
}
} else {
// sleep infinitely
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 @@ -634,3 +634,7 @@ Sometimes, you may wish to not have the entrypoint copy the binary file onto the
If you wish to have auto configuration use the `readinessindicatorfile` in the configuration, you can use the `--readiness-indicator-file` to express which file should be used as the readiness indicator.

--readiness-indicator-file=/path/to/file

The thin plugin will reconcile its kubeconfig and config file every second when using `--cleanup-config-on-exit` and `--multus-conf-file=auto`. The config poll interval is configurable with `--multus-config-watch-timer=<duration>`

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