Skip to content

Commit

Permalink
Merge pull request kubernetes#25809 from cjwagner/crier-graceful-term…
Browse files Browse the repository at this point in the history
…ination

Make Crier gracefully terminate when interrupted.
  • Loading branch information
k8s-ci-robot authored Mar 30, 2022
2 parents cc63d04 + dd05042 commit 1fc67a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions prow/cmd/crier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,10 @@ func main() {
}

hasReporter = true
if err := crier.New(mgr, gcsreporter.New(cfg, opener, o.dryrun), o.blobStorageWorkers, o.githubEnablement.EnablementChecker()); err != nil {
logrus.WithError(err).Fatal("failed to construct gcsreporter controller")
if o.blobStorageWorkers > 0 {
if err := crier.New(mgr, gcsreporter.New(cfg, opener, o.dryrun), o.blobStorageWorkers, o.githubEnablement.EnablementChecker()); err != nil {
logrus.WithError(err).Fatal("failed to construct gcsreporter controller")
}
}

if o.k8sBlobStorageWorkers > 0 {
Expand All @@ -313,8 +315,11 @@ func main() {
// Push metrics to the configured prometheus pushgateway endpoint or serve them
metrics.ExposeMetrics("crier", cfg().PushGateway, o.instrumentationOptions.MetricsPort)

if err := mgr.Start(interrupts.Context()); err != nil {
logrus.WithError(err).Fatal("controller manager failed")
}
interrupts.Run(func(ctx context.Context) {
if err := mgr.Start(ctx); err != nil {
logrus.WithError(err).Fatal("Controller manager exited with error.")
}
})
interrupts.WaitForGracefulShutdown()
logrus.Info("Ended gracefully")
}
2 changes: 1 addition & 1 deletion prow/interrupts/interrupts.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func WaitForGracefulShutdown() {
}
}

// Context returns a context that stays is cancelled when an interrupt hits.
// Context returns a context that is cancelled when an interrupt hits.
// Using this context is a weak guarantee that your work will finish before
// process exit as callers cannot signal that they are finished. Prefer to use
// Run().
Expand Down

0 comments on commit 1fc67a5

Please sign in to comment.