fix: restore watcher if channel is closed
This commit is contained in:
parent
6f91ad607f
commit
4d6b06efe7
@ -17,12 +17,12 @@ import (
|
||||
func (crd Crd) watchFlinkJobs(ch chan FlinkJobCrdEvent) {
|
||||
|
||||
go func() {
|
||||
for {
|
||||
pkg.Logger.Debug("[crd] starting watch")
|
||||
watcher, err := crd.client.Watch(context.Background(), metaV1.ListOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer watcher.Stop()
|
||||
namespace := os.Getenv("NAMESPACE")
|
||||
pkg.Logger.Debug("[crd] [watch]", zap.String("namespace", namespace))
|
||||
for event := range watcher.ResultChan() {
|
||||
@ -62,7 +62,9 @@ func (crd Crd) watchFlinkJobs(ch chan FlinkJobCrdEvent) {
|
||||
crd.remove(job.UID)
|
||||
}
|
||||
}
|
||||
|
||||
defer watcher.Stop()
|
||||
pkg.Logger.Warn("[crd] [watch] Watcher stopped, restarting...")
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user