Open jiridanek opened 1 month ago
^^ that nested context does not seem to be good enough, I still see unclean shutdowns
resolved by suppressing DEBUG logs
I like the suggestion of using
// Set the GracefulShutdownTimeout to 0 to prevent errors: // failed waiting for all runnables to end within grace period of 30s: context deadline exceeded // Ref: https://github.com/kubernetes-sigs/controller-runtime/blob/e59161ee/pkg/manager/internal.go#L543-L548 cfg.GracefulShutdownTimeout = lo.ToPtr(time.Duration(0))
The webhook timeout cannot be changed
idleConnsClosed := make(chan struct{})
go func() {
<-ctx.Done()
log.Info("Shutting down webhook server with timeout of 1 minute")
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel()
if err := srv.Shutdown(ctx); err != nil {
// Error from closing listeners, or context timeout
log.Error(err, "error shutting down the HTTP server")
}
close(idleConnsClosed)
}()
One more advice, similarly to the previous, I found one other likely option in the struct docs
BaseContext: func() context.Context {
return ctx
},
Waiting for
err = mgr.Start(ctx)
to return (after ctx is cancelled) and only then calling
err := envTest.Stop()
seems to be effective against
2024-11-17T20:19:57+01:00 ERROR controller-runtime.certwatcher error re-reading certificate {"error": "open /var/folders/f1/3m518k5d34l72v_9nqyjzqm80000gn/T/envtest-serving-certs-737480808/tls.crt: no such file or directory"}
Harmless, but annoying
This is something that people in general struggled with
and we have a TODO comment for it
https://github.com/opendatahub-io/kubeflow/blob/0743e0e444f236b75d90eb2053ac0e79ead5950f/components/odh-notebook-controller/controllers/suite_test.go#L189-L195
The solution seems to be to create a nested context for
but it needs to be checked.