From 7a11b4def78e5b4506611fe85d083a12b695bd05 Mon Sep 17 00:00:00 2001 From: Philipp Sauter Date: Fri, 10 Jun 2022 22:17:10 +0200 Subject: [PATCH] fix: make `talosctl bootstrap` accept only single node Previously talosctl would accept multiple nodes for the bootstrap command which is a strictly single-node operation. Talosctl will abort the bootstrap command if more than one node is specified either as a command-line flag or in talosconfig. Fixes #5636 Signed-off-by: Philipp Sauter --- cmd/talosctl/cmd/talos/bootstrap.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/talosctl/cmd/talos/bootstrap.go b/cmd/talosctl/cmd/talos/bootstrap.go index 11a12cb830..dc63f68811 100644 --- a/cmd/talosctl/cmd/talos/bootstrap.go +++ b/cmd/talosctl/cmd/talos/bootstrap.go @@ -37,6 +37,10 @@ Talos etcd cluster can be recovered from a known snapshot with '--recover-from=' Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return WithClient(func(ctx context.Context, c *client.Client) error { + if len(Nodes) > 1 { + return fmt.Errorf("command \"bootstrap\" is not supported with multiple nodes") + } + if bootstrapCmdFlags.recoverFrom != "" { manager := snapshot.NewV3(logging.Wrap(os.Stderr)) @@ -65,7 +69,7 @@ Talos etcd cluster can be recovered from a known snapshot with '--recover-from=' RecoverEtcd: bootstrapCmdFlags.recoverFrom != "", RecoverSkipHashCheck: bootstrapCmdFlags.recoverSkipHashCheck, }); err != nil { - return fmt.Errorf("error executing bootstrap: %s", err) + return fmt.Errorf("error executing bootstrap: %w", err) } return nil