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>
(cherry picked from commit 3d4c2cf2cf)
This commit is contained in:
Brad Davidson
2025-08-12 00:18:57 +00:00
committed by Brad Davidson
parent cdca7417be
commit ee389cb9d4

View File

@@ -10,6 +10,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"
@@ -82,6 +83,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)
if err := checkCerts(nodeMap, time.Hour*24*daemonconfig.CertificateRenewDays); err != nil {
message := fmt.Sprintf("Node certificates require attention - restart %s on this node to trigger automatic rotation: %v", version.Program, err)