From 1afcb8917ab004301abfce77aa348658ecce61e9 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Fri, 15 May 2026 20:54:14 +0000 Subject: [PATCH] Bump kine for sql perf improvements Signed-off-by: Brad Davidson --- go.mod | 1 + go.sum | 4 ++-- pkg/cli/server/server.go | 3 +++ pkg/cluster/cluster.go | 13 +++++++++---- tests/unit.go | 4 ++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index c6487501c8a..74c271e4541 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ replace ( github.com/google/cadvisor => github.com/k3s-io/cadvisor v0.52.1 github.com/google/gnostic-models => github.com/google/gnostic-models v0.6.9 github.com/googleapis/gax-go/v2 => github.com/googleapis/gax-go/v2 v2.12.0 + github.com/k3s-io/kine => github.com/brandond/kine v0.15.1-bd.10 github.com/opencontainers/cgroups => github.com/opencontainers/cgroups v0.0.5 github.com/opencontainers/runc => github.com/opencontainers/runc v1.4.2 github.com/opencontainers/selinux => github.com/opencontainers/selinux v1.13.0 diff --git a/go.sum b/go.sum index 8f264167d37..d0f42c78a16 100644 --- a/go.sum +++ b/go.sum @@ -305,6 +305,8 @@ github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/brandond/kine v0.15.1-bd.10 h1:28tIEEO8gMIKd8jVEvTw6rT3aMNYrDRAwcqAZqDU29o= +github.com/brandond/kine v0.15.1-bd.10/go.mod h1:G3bF+43KaA5h2BEVrmurS+0ryzXksiJ36C0BnszVUKI= github.com/bronze1man/goStrongswanVici v0.0.0-20231128135937-211cef3b0b20 h1:JMoL5xJSYxo1QVJ3c+4FutWQnks3gZX9DYkgAnvg+5g= github.com/bronze1man/goStrongswanVici v0.0.0-20231128135937-211cef3b0b20/go.mod h1:fWUtBEPt2yjrr3WFhOqvajM8JSEU8bEeBcoeSCsKRpc= github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk= @@ -870,8 +872,6 @@ github.com/k3s-io/etcd/server/v3 v3.6.7-k3s1 h1:ZBV6n9XhjGex9MIOaEAefbhNriH5Gxo4 github.com/k3s-io/etcd/server/v3 v3.6.7-k3s1/go.mod h1:LEM328bPA2uVMhN0+Ht/vAsADW127QS1oM7EuHrOTy0= github.com/k3s-io/helm-controller v0.17.1 h1:LjZelVfddI5CWFAI5zlkRVhxobpSLRnNA/R9qU706k0= github.com/k3s-io/helm-controller v0.17.1/go.mod h1:5cuEedP5BgBkWpUO1C3BY05hnaBLycsm/2PsW3DY6WE= -github.com/k3s-io/kine v0.15.0 h1:KRb+DrZFd8YLRNbeAt+UYpyaCHCwJlilFVSrrkvpndc= -github.com/k3s-io/kine v0.15.0/go.mod h1:G3bF+43KaA5h2BEVrmurS+0ryzXksiJ36C0BnszVUKI= github.com/k3s-io/klog/v2 v2.140.0-k3s1 h1:Z6S9oqaxcKtLaTcQNgWsaZNE5a+qJmCrTI+Lahor4X8= github.com/k3s-io/klog/v2 v2.140.0-k3s1/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= github.com/k3s-io/kube-router/v2 v2.6.3-k3s1 h1:RZjUBIuitXCuYoCzm1aM6p5EgQFC5k3N72j4pBIc2j4= diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index b6e3257b328..5596a9c25f1 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -84,6 +84,9 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont // If exiting due to an error, ensure that contexts are cancelled so that the // WaitGroup exits. Otherwise, wait for something else to initiate shutdown. defer func() { + if r := recover(); r != nil { + rerr = fmt.Errorf("server panicked: %v", r) + } if rerr != nil { // do not need to pass the error in here, it will be reported by the CLI error handler signals.RequestShutdown(nil) diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index bcecb861560..e3418ad0868 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -182,11 +182,16 @@ func (c *Cluster) startStorage(ctx context.Context, bootstrap bool) error { }() c.storageRunning = true - if !bootstrap { - // only register metrics when not bootstrapping, to prevent - // multiple datastore metrics from being registered. + if !c.config.KineTLS { + // if TLS is not enabled for kine, storage will only be started once, + // so go ahead and register metrics now c.config.Datastore.MetricsRegisterer = metrics.DefaultRegisterer - // set the tls config for the kine storage + } + if !bootstrap { + // only register metrics after boostrapping is done, to prevent + // multiple datastore metrics from being registered + c.config.Datastore.MetricsRegisterer = metrics.DefaultRegisterer + // set the tls config for the kine storage, once bootstrapped c.config.Datastore.ServerTLSConfig.CAFile = c.config.Runtime.ETCDServerCA c.config.Datastore.ServerTLSConfig.CertFile = c.config.Runtime.ServerETCDCert c.config.Datastore.ServerTLSConfig.KeyFile = c.config.Runtime.ServerETCDKey diff --git a/tests/unit.go b/tests/unit.go index d385815ccc6..949aae6fb52 100644 --- a/tests/unit.go +++ b/tests/unit.go @@ -7,6 +7,8 @@ import ( "github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/control/deps" + "github.com/k3s-io/k3s/pkg/metrics" + "github.com/prometheus/client_golang/prometheus" ) // GenerateDataDir creates a temporary directory at "/tmp/k3s//". @@ -43,6 +45,8 @@ func CleanupDataDir(cnf *config.Control) { // GenerateRuntime creates a temporary data dir and configures // config.ControlRuntime with all the appropriate certificate keys. func GenerateRuntime(cnf *config.Control) error { + // reset metrics registerer to avoid panicing if test cover metrics registration + metrics.DefaultRegisterer = prometheus.NewRegistry() // reuse ready channel from existing runtime if set cnf.Runtime = config.NewRuntime() if err := GenerateDataDir(cnf); err != nil {