Skip to content

Shutdown manager if webhook & metrics server cert-watchers fail #3413

Open

Description

@sbueringer

Just recently noticed that the webhook & metrics server are starting certWatchers like this

		go func() {
			if err := certWatcher.Start(ctx); err != nil {
				log.Error(err, "certificate watcher error")
			}
		}()

If the cert-watcher is failing we only log this error and that's it. As soon as the certs are rotated again the servers will use outdated certificates.
If this is somehow covered by a livenessProbe the manager will restart otherwise it won't.

I think we should look into how we can shutdown the manager / restart the binary if one of these cert-watchers fail.

One option might be to ensure the Start func of the servers return an error when the cert-watcher fails.

Activity

  1. sbueringer commented on Jan 8, 2026

    @sbueringer
    MemberAuthor
  2. alvaroaleman commented on Jan 8, 2026

    @alvaroaleman
    Member

    yeah this seems bad, maybe we can find a way to add the certwatchers to the manager rather than having to deal with it failing in the webhook/metrics server?

  3. sbueringer commented on Jan 9, 2026

    @sbueringer
    MemberAuthor

    I was thinking that maybe handling it internally is cleaner than somehow trying to connect the certwatcher runnables to the manager. But maybe there's a clean way to do that.

    In general it would be nice if the certwatcher stays an implementation detail of these servers (and as these servers are already runnables themselves I thought it's nice if they just keep an eye on their certwatchers)

    But no strong opinion

  4. k8s-triage-robot commented on Apr 9, 2026

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  5. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Apr 9, 2026
  6. sbueringer commented on Apr 29, 2026

    @sbueringer
    MemberAuthor

    /remove-lifecycle stale

  7. removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Apr 29, 2026
  8. GaurangKhanderay commented on Jul 24, 2026

    @GaurangKhanderay

    I'd like to work on this.

    After looking through the code, it seems like both the webhook server and metrics server already implement Runnable, and their Start() methods can propagate errors back to the manager.

    The missing piece appears to be the certWatcher.Start(ctx) goroutine. Currently, if the watcher fails, the error is only logged:

    go func() {
    if err := certWatcher.Start(ctx); err != nil {
    log.Error(err, "certificate watcher error")
    }
    }()

    This means the failure does not reach the existing runnable error handling path.

    I'm thinking of keeping the cert watcher as an internal implementation detail of the webhook/metrics servers and propagating its failure through the existing Start() error contract, instead of making cert watchers separate manager runnables. This seems aligned with the discussion above and avoids changes to manager runnable orchestration.

    One design question before I start: should a cert-watcher failure always be fatal (triggering manager shutdown), or is there appetite for retry/recovery within the server first?

  9. sbueringer commented on Jul 31, 2026

    @sbueringer
    MemberAuthor

    Please stop posting AI generated comments, thx!

  10. somtochiama commented on Oct 13, 2026

    @somtochiama

    @sbueringer I'd like to pick this up if that's okay. I am leaning towardds keeping the cert-watchers in the metrics/webhook servers and having the start function fail if they don't start.

  11. sbueringer commented on Oct 19, 2026

    @sbueringer
    MemberAuthor

    I took another look. I still think #3413 (comment) is the way to go compared to adding the metrics/webhook servers cert-watchers to the manager

    @alvaroaleman is that okay for you as well?

  12. alvaroaleman commented on Oct 19, 2026

    @alvaroaleman
    Member

    Yeah for as long as we ensure that the corresponding runnables fail which should then typically cause the manager to fail, that seems fine

  13. sbueringer commented on Oct 19, 2026

    @sbueringer
    MemberAuthor

    @somtochiama Feel free to go ahead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions