mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-05 16:27:05 +00:00
topology-updater: make it possible to disable sleep-interval
Especially convenient for testing porpuses and completely harmless Signed-off-by: Talor Itzhak <titzhak@redhat.com>
This commit is contained in:
parent
8afd819132
commit
8924213d14
3 changed files with 9 additions and 5 deletions
|
@ -134,7 +134,7 @@ func initFlags(flagset *flag.FlagSet) (*topology.Args, *resourcemonitor.Args) {
|
||||||
flagset.StringVar(&args.KubeConfigFile, "kubeconfig", "",
|
flagset.StringVar(&args.KubeConfigFile, "kubeconfig", "",
|
||||||
"Kube config file.")
|
"Kube config file.")
|
||||||
flagset.DurationVar(&resourcemonitorArgs.SleepInterval, "sleep-interval", time.Duration(60)*time.Second,
|
flagset.DurationVar(&resourcemonitorArgs.SleepInterval, "sleep-interval", time.Duration(60)*time.Second,
|
||||||
"Time to sleep between CR updates. Non-positive value implies no CR updatation (i.e. infinite sleep). [Default: 60s]")
|
"Time to sleep between CR updates. zero means no CR updates on interval basis. [Default: 60s]")
|
||||||
flagset.StringVar(&resourcemonitorArgs.Namespace, "watch-namespace", "*",
|
flagset.StringVar(&resourcemonitorArgs.Namespace, "watch-namespace", "*",
|
||||||
"Namespace to watch pods (for testing/debugging purpose). Use * for all namespaces.")
|
"Namespace to watch pods (for testing/debugging purpose). Use * for all namespaces.")
|
||||||
flagset.StringVar(&resourcemonitorArgs.KubeletConfigURI, "kubelet-config-uri", "",
|
flagset.StringVar(&resourcemonitorArgs.KubeletConfigURI, "kubelet-config-uri", "",
|
||||||
|
|
|
@ -77,8 +77,7 @@ nfd-topology-updater -oneshot -no-publish
|
||||||
### -sleep-interval
|
### -sleep-interval
|
||||||
|
|
||||||
The `-sleep-interval` specifies the interval between resource hardware
|
The `-sleep-interval` specifies the interval between resource hardware
|
||||||
topology re-examination (and CR updates). A non-positive value implies
|
topology re-examination (and CR updates). zero means no CR updates on interval basis.
|
||||||
infinite sleep interval, i.e. no re-detection is done.
|
|
||||||
|
|
||||||
Default: 60s
|
Default: 60s
|
||||||
|
|
||||||
|
|
|
@ -63,10 +63,15 @@ func New(sleepInterval time.Duration, dest chan<- Info, kubeletStateDir string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Notifier) Run() {
|
func (n *Notifier) Run() {
|
||||||
t := time.Tick(n.sleepInterval)
|
timeEvents := make(<-chan time.Time)
|
||||||
|
if n.sleepInterval > 0 {
|
||||||
|
ticker := time.NewTicker(n.sleepInterval)
|
||||||
|
timeEvents = ticker.C
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-t:
|
case <-timeEvents:
|
||||||
klog.V(5).Infof("timer update received")
|
klog.V(5).Infof("timer update received")
|
||||||
i := Info{Event: IntervalBased}
|
i := Info{Event: IntervalBased}
|
||||||
n.dest <- i
|
n.dest <- i
|
||||||
|
|
Loading…
Add table
Reference in a new issue