This commit is contained in:
Brad Davidson 2026-05-26 10:17:00 +00:00 committed by GitHub
commit f8ccae4981
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 6 deletions

1
go.mod
View file

@ -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

4
go.sum
View file

@ -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=

View file

@ -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)

View file

@ -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

View file

@ -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/<RANDOM_STRING>/".
@ -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 {