Fix cert startup check events

Ensure that cert checks don't run until after the apiserver is ready to receive events

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
Brad Davidson 2025-08-12 00:18:57 +00:00 committed by Brad Davidson
parent f62f1d6c91
commit 3d4c2cf2cf

View file

@ -11,6 +11,7 @@ import (
daemonconfig "github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/k3s-io/k3s/pkg/daemons/control/deps"
"github.com/k3s-io/k3s/pkg/daemons/executor"
"github.com/k3s-io/k3s/pkg/metrics"
"github.com/k3s-io/k3s/pkg/util"
"github.com/k3s-io/k3s/pkg/util/services"
@ -84,6 +85,9 @@ func Setup(ctx context.Context, nodeConfig *daemonconfig.Node, dataDir string) e
}
go wait.Until(func() {
// don't check and create events until after the apiserver is up, otherwise the events may be lost.
<-executor.APIServerReadyChan()
logrus.Debugf("Running %s certificate expiration check", controllerName)
var hasErr bool
if err := checkCerts(nodeMap, time.Hour*24*daemonconfig.CertificateRenewDays); err != nil {