Skip to content

Commit

Permalink
Handle cluster join as create if we're the only member
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Dec 13, 2024
1 parent b55aaeb commit 838f446
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ func (e *ETCD) join(ctx context.Context, clientAccessInfo *clientaccess.Info) er
defer cancel()

var (
state string
cluster []string
add = true
)
Expand Down Expand Up @@ -620,12 +621,19 @@ func (e *ETCD) join(ctx context.Context, clientAccessInfo *clientaccess.Info) er
return err
}
cluster = append(cluster, fmt.Sprintf("%s=%s", e.name, e.peerURL()))
state = "existing"
} else if len(cluster) > 1 {
logrus.Infof("Starting etcd to join cluster with members %v", cluster)
state = "existing"
} else {
logrus.Infof("Starting etcd for new cluster")
state = "new"
}

logrus.Infof("Starting etcd to join cluster with members %v", cluster)
return e.cluster(ctx, false, executor.InitialOptions{
Cluster: strings.Join(cluster, ","),
State: "existing",
AdvertisePeerURL: e.peerURL(),
Cluster: strings.Join(cluster, ","),
State: state,
})
}

Expand Down

0 comments on commit 838f446

Please sign in to comment.