From c8cb018203b6264e16adb16c0ed7d62cdf287131 Mon Sep 17 00:00:00 2001 From: Shreyas Rao <42259948+shreyas-s-rao@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:59:07 +0530 Subject: [PATCH] Skip scale-up checks for first member of etcd cluster. (#649) (#654) Co-authored-by: Ishan Tyagi <42602577+ishan16696@users.noreply.github.com> --- pkg/initializer/initializer.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/initializer/initializer.go b/pkg/initializer/initializer.go index d887d4d7f..48dc6be9d 100644 --- a/pkg/initializer/initializer.go +++ b/pkg/initializer/initializer.go @@ -19,6 +19,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "time" "github.com/gardener/etcd-backup-restore/pkg/errors" @@ -57,8 +58,15 @@ func (e *EtcdInitializer) Initialize(mode validator.Mode, failBelowRevision int6 ctx := context.Background() var err error - //Etcd cluster scale-up case - if miscellaneous.IsMultiNode(logger) { + podName, err := miscellaneous.GetEnvVarOrError("POD_NAME") + if err != nil { + logger.Fatalf("Error reading POD_NAME env var : %v", err) + } + + // Etcd cluster scale-up case + // Note: first member of etcd cluster can never be part of scale-up case. + // TODO: consider removing this special check for first cluster member when backup-restore can check presence of any member in cluster. + if miscellaneous.IsMultiNode(logger) && !strings.HasSuffix(podName, "0") { clientSet, err := miscellaneous.GetKubernetesClientSetOrError() if err != nil { logger.Fatalf("failed to create clientset, %v", err)