Skip to content

Commit

Permalink
Parameterize config watcher loop speed
Browse files Browse the repository at this point in the history
This loop spins really quickly otherwise. This will allow cluster
operators to choose how quickly the thin plugin reconciles the
kubeconfig in the event of a stale service account token.

BUG: #1232
Signed-off-by: Connor Kuehl <[email protected]>
Signed-off-by: Chris Chiu <[email protected]>
  • Loading branch information
Connor Kuehl authored and mschiu77 committed Aug 12, 2024
1 parent 3c33f6f commit 73d11b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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>`

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

0 comments on commit 73d11b8

Please sign in to comment.