mirror of https://github.com/k3s-io/k3s
Fix etcd snapshot reconcile for agentless nodes
Disable cleanup of orphaned snapshots and patching of node annotations if running agentless Signed-off-by: Brad Davidson <brad.davidson@rancher.com>pull/9838/head
parent
7474a6fa43
commit
edb0440017
|
@ -167,6 +167,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
|
||||||
serverConfig.ControlConfig.DisableAPIServer = cfg.DisableAPIServer
|
serverConfig.ControlConfig.DisableAPIServer = cfg.DisableAPIServer
|
||||||
serverConfig.ControlConfig.DisableScheduler = cfg.DisableScheduler
|
serverConfig.ControlConfig.DisableScheduler = cfg.DisableScheduler
|
||||||
serverConfig.ControlConfig.DisableControllerManager = cfg.DisableControllerManager
|
serverConfig.ControlConfig.DisableControllerManager = cfg.DisableControllerManager
|
||||||
|
serverConfig.ControlConfig.DisableAgent = cfg.DisableAgent
|
||||||
serverConfig.ControlConfig.EmbeddedRegistry = cfg.EmbeddedRegistry
|
serverConfig.ControlConfig.EmbeddedRegistry = cfg.EmbeddedRegistry
|
||||||
serverConfig.ControlConfig.ClusterInit = cfg.ClusterInit
|
serverConfig.ControlConfig.ClusterInit = cfg.ClusterInit
|
||||||
serverConfig.ControlConfig.EncryptSecrets = cfg.EncryptSecrets
|
serverConfig.ControlConfig.EncryptSecrets = cfg.EncryptSecrets
|
||||||
|
|
|
@ -181,6 +181,7 @@ type Control struct {
|
||||||
DataDir string
|
DataDir string
|
||||||
Datastore endpoint.Config `json:"-"`
|
Datastore endpoint.Config `json:"-"`
|
||||||
Disables map[string]bool
|
Disables map[string]bool
|
||||||
|
DisableAgent bool
|
||||||
DisableAPIServer bool
|
DisableAPIServer bool
|
||||||
DisableControllerManager bool
|
DisableControllerManager bool
|
||||||
DisableETCD bool
|
DisableETCD bool
|
||||||
|
|
|
@ -850,6 +850,12 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Agentless servers do not have a node. If we are running agentless, return early to avoid pruning
|
||||||
|
// snapshots for nonexistent nodes and trying to patch the reconcile annotations on our node.
|
||||||
|
if e.config.DisableAgent {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// List all snapshots in Kubernetes not stored on S3 or a current etcd node.
|
// List all snapshots in Kubernetes not stored on S3 or a current etcd node.
|
||||||
// These snapshots are local to a node that no longer runs etcd and cannot be restored.
|
// These snapshots are local to a node that no longer runs etcd and cannot be restored.
|
||||||
// If the node rejoins later and has local snapshots, it will reconcile them itself.
|
// If the node rejoins later and has local snapshots, it will reconcile them itself.
|
||||||
|
|
|
@ -2,6 +2,7 @@ package etcd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -176,6 +177,23 @@ func (e *etcdSnapshotHandler) reconcile() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If running without an agent there will not be a node for this server;
|
||||||
|
// create a dummy node and assume it has reconciled.
|
||||||
|
if e.etcd.config.DisableAgent {
|
||||||
|
node := v1.Node{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: os.Getenv("NODE_NAME"),
|
||||||
|
Annotations: map[string]string{
|
||||||
|
annotationLocalReconciled: "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if e.etcd.s3 != nil {
|
||||||
|
node.Annotations[annotationS3Reconciled] = "true"
|
||||||
|
}
|
||||||
|
nodeList.Items = append(nodeList.Items, node)
|
||||||
|
}
|
||||||
|
|
||||||
// Once a node has set the reconcile annotation, it is considered to have
|
// Once a node has set the reconcile annotation, it is considered to have
|
||||||
// migrated to using ETCDSnapshotFile resources, and any old configmap
|
// migrated to using ETCDSnapshotFile resources, and any old configmap
|
||||||
// entries for it can be pruned. Until the annotation is set, we will leave
|
// entries for it can be pruned. Until the annotation is set, we will leave
|
||||||
|
|
Loading…
Reference in New Issue