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

fix(inventory/operator): exit node monitor when pods watcher closes #197

Merged
merged 1 commit into from
Feb 19, 2024
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
15 changes: 13 additions & 2 deletions operator/inventory/node-discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import (
"github.com/akash-network/provider/tools/fromctx"
)

var (
errWorkerExit = errors.New("worker finished")
)

type k8sPatch struct {
Op string `json:"op"`
Path string `json:"path"`
Expand Down Expand Up @@ -266,7 +270,10 @@ initloop:
select {
case <-dp.ctx.Done():
return dp.ctx.Err()
case evt := <-watcher.ResultChan():
case evt, isopen := <-watcher.ResultChan():
if !isopen {
return errWorkerExit
}
resp := evt.Object.(*corev1.Pod)
if resp.Status.Phase == corev1.PodRunning {
watcher.Stop()
Expand Down Expand Up @@ -460,7 +467,11 @@ func (dp *nodeDiscovery) monitor() error {
signalLabels()
}
}
case res := <-podsWatch.ResultChan():
case res, isopen := <-podsWatch.ResultChan():
if !isopen {
return errWorkerExit
}

obj := res.Object.(*corev1.Pod)
switch res.Type {
case watch.Added:
Expand Down
Loading