mirror of
https://git.vectorsigma.ru/public/k3s.git
synced 2026-08-03 04:09:48 +00:00
[Release-1.26] Clear remove annotations on cluster reset (#8590)
* Use admin kubeconfig instead of supervisor for etcd snapshot CLI Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Skip creating CRDs and setting up event recorder for CLI controller context Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Don't export functions not needed outside the etcd package Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Reorganize Driver interface and etcd driver to avoid passing context and config into most calls Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Clear remove annotations on cluster reset; refuse to delete last member from cluster Signed-off-by: Brad Davidson <brad.davidson@rancher.com> --------- Signed-off-by: Brad Davidson <brad.davidson@rancher.com> Co-authored-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/k3s-io/k3s/pkg/daemons/config"
|
||||
"github.com/k3s-io/k3s/pkg/etcd"
|
||||
"github.com/k3s-io/k3s/pkg/version"
|
||||
"github.com/rancher/dynamiclistener"
|
||||
"github.com/rancher/dynamiclistener/factory"
|
||||
@@ -33,9 +32,14 @@ import (
|
||||
// and will sync the certs into the Kubernetes datastore, with a local disk cache.
|
||||
func (c *Cluster) newListener(ctx context.Context) (net.Listener, http.Handler, error) {
|
||||
if c.managedDB != nil {
|
||||
if _, err := os.Stat(etcd.ResetFile(c.config)); err == nil {
|
||||
// delete the dynamic listener file if it exists after restoration to fix restoration
|
||||
// on fresh nodes
|
||||
resetDone, err := c.managedDB.IsReset()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if resetDone {
|
||||
// delete the dynamic listener TLS secret cache after restoring,
|
||||
// to ensure that dynamiclistener doesn't sync the old secret over the top
|
||||
// of whatever was just restored.
|
||||
os.Remove(filepath.Join(c.config.DataDir, "tls/dynamic-cert.json"))
|
||||
}
|
||||
}
|
||||
@@ -104,8 +108,8 @@ func (c *Cluster) initClusterAndHTTPS(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Config the cluster database and allow it to add additional request handlers
|
||||
handler, err = c.initClusterDB(ctx, handler)
|
||||
// Register database request handlers and controller callbacks
|
||||
handler, err = c.registerDBHandlers(handler)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user