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

Remove code duplication that disable the gather #350

Merged
Merged
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
17 changes: 8 additions & 9 deletions pkg/controller/periodic/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,10 @@ func (c *Controller) Run(stopCh <-chan struct{}, initialDelay time.Duration) {
case <-stopCh:
return
case <-time.After(initialDelay):
if c.configurator.Config().Report {
c.Gather()
}
}
} else {
if c.configurator.Config().Report {
c.Gather()
}
} else {
c.Gather()
}

go wait.Until(func() { c.periodicTrigger(stopCh) }, time.Second, stopCh)
Expand All @@ -86,6 +82,11 @@ func (c *Controller) Run(stopCh <-chan struct{}, initialDelay time.Duration) {
// Currently their is only 1 gatherer (clusterconfig) and no new gatherer is on the horizon.
// Running the gatherers in parallel should be a future improvement when a new gatherer is introduced.
func (c *Controller) Gather() {
if !c.configurator.Config().Report {
klog.V(3).Info("Gather is disabled by configuration.")
return
}

interval := c.configurator.Config().Interval
threshold := status.GatherFailuresCountThreshold
duration := interval / (time.Duration(threshold) * 2)
Expand Down Expand Up @@ -153,9 +154,7 @@ func (c *Controller) periodicTrigger(stopCh <-chan struct{}) {
klog.Infof("Gathering cluster info every %s", interval)

case <-time.After(interval):
if c.configurator.Config().Report {
c.Gather()
}
c.Gather()
}
}
}