Skip to content

Commit 3d0c2ad

Browse files
vdemeesterShivam Mukhade
authored andcommitted
Force controller & watcher goroutine to start "early"
Signed-off-by: Vincent Demeester <[email protected]>
1 parent 779a4fa commit 3d0c2ad

File tree

2 files changed

+8
-0
lines changed
  • cmd

2 files changed

+8
-0
lines changed

cmd/pipelines-as-code-controller/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ func main() {
2828
log.Fatal("failed to init kinit client : ", err)
2929
}
3030

31+
c := make(chan struct{})
3132
go func() {
33+
c <- struct{}{}
3234
if err := run.WatchConfigMapChanges(ctx, run); err != nil {
3335
log.Fatal(err)
3436
}
3537
}()
38+
// Force WatchConfigMapChanges go routines to actually start
39+
<-c
3640

3741
evadapter.MainWithContext(ctx, PACControllerLogKey, adapter.NewEnvConfig, adapter.New(run, kinteract))
3842
}

cmd/pipelines-as-code-watcher/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ func main() {
2525
w.WriteHeader(200)
2626
_, _ = fmt.Fprint(w, "ok")
2727
})
28+
29+
c := make(chan struct{})
2830
go func() {
31+
c <- struct{}{}
2932
// start the web server on port and accept requests
3033
log.Printf("Readiness and health check server listening on port %s", probesPort)
3134
// timeout values same as default one from triggers eventlistener
@@ -38,6 +41,7 @@ func main() {
3841
}
3942
log.Fatal(srv.ListenAndServe())
4043
}()
44+
<-c
4145

4246
sharedmain.Main("pac-watcher", reconciler.NewController())
4347
}

0 commit comments

Comments
 (0)