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

Watchdog waits an entire period before first tick #11094

Closed
lahabana opened this issue Aug 12, 2024 · 1 comment · Fixed by #11105
Closed

Watchdog waits an entire period before first tick #11094

lahabana opened this issue Aug 12, 2024 · 1 comment · Fixed by #11105
Labels
kind/bug A bug triage/accepted The issue was reviewed and is complete enough to start working on it

Comments

@lahabana
Copy link
Contributor

lahabana commented Aug 12, 2024

What happened?

From the code:

func (w *SimpleWatchdog) Start(stop <-chan struct{}) {
ticker := w.NewTicker()
defer ticker.Stop()
for {
ctx, cancel := context.WithCancel(context.Background())
// cancel is called at the end of the loop
go func() {
select {
case <-stop:
cancel()
case <-ctx.Done():
}
}()
select {
case <-ticker.C:
select {
case <-stop:
default:
if err := w.onTick(ctx); err != nil && !errors.Is(err, context.Canceled) {
w.OnError(err)
}
}
case <-stop:
if w.OnStop != nil {
w.OnStop()
}
// cancel will be called by the above goroutine
return
}
cancel()
}
}

We probably should not wait an entire tick before triggering first call. This can delay things unecessarilly (for example sending the configuration).

@lahabana lahabana added triage/pending This issue will be looked at on the next triage meeting kind/bug A bug labels Aug 12, 2024
@slonka
Copy link
Contributor

slonka commented Aug 12, 2024

triage: accepted

@slonka slonka added triage/accepted The issue was reviewed and is complete enough to start working on it and removed triage/pending This issue will be looked at on the next triage meeting labels Aug 12, 2024
lahabana added a commit to lahabana/kuma that referenced this issue Aug 13, 2024
This makes the code simpler and easier to track

xref kumahq#11094

Signed-off-by: Charly Molter <[email protected]>
lahabana added a commit that referenced this issue Sep 10, 2024
* fix(kuma-cp): use contexts instead of channels in watchdog

This makes the code simpler and easier to track

xref #11094

Signed-off-by: Charly Molter <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug triage/accepted The issue was reviewed and is complete enough to start working on it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants