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) {
|
func (crd Crd) watchFlinkJobs(ch chan FlinkJobCrdEvent) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
for {
|
||||||
pkg.Logger.Debug("[crd] starting watch")
|
pkg.Logger.Debug("[crd] starting watch")
|
||||||
watcher, err := crd.client.Watch(context.Background(), metaV1.ListOptions{})
|
watcher, err := crd.client.Watch(context.Background(), metaV1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer watcher.Stop()
|
|
||||||
namespace := os.Getenv("NAMESPACE")
|
namespace := os.Getenv("NAMESPACE")
|
||||||
pkg.Logger.Debug("[crd] [watch]", zap.String("namespace", namespace))
|
pkg.Logger.Debug("[crd] [watch]", zap.String("namespace", namespace))
|
||||||
for event := range watcher.ResultChan() {
|
for event := range watcher.ResultChan() {
|
||||||
@ -62,7 +62,9 @@ func (crd Crd) watchFlinkJobs(ch chan FlinkJobCrdEvent) {
|
|||||||
crd.remove(job.UID)
|
crd.remove(job.UID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
defer watcher.Stop()
|
||||||
|
pkg.Logger.Warn("[crd] [watch] Watcher stopped, restarting...")
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user