Skip to content

Commit

Permalink
fix: build correctly etcd initial cluster URL
Browse files Browse the repository at this point in the history
The supposed format with multiple adverised URLs is:

`name=u1,name=u2`

Previously Talos generated:

`name=u1,u2`

(which is wrong)

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Jan 20, 2023
1 parent ae83b10 commit 00e52ae
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/app/machined/pkg/system/services/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (e *Etcd) argsForInit(ctx context.Context, r runtime.Runtime, spec *etcdres
}

if ok {
initialCluster := fmt.Sprintf("%s=%s", spec.Name, formatEtcdURLs(spec.AdvertisedAddresses, constants.EtcdPeerPort))
initialCluster := formatClusterURLs(spec.Name, getEtcdURLs(spec.AdvertisedAddresses, constants.EtcdPeerPort))

if upgraded {
denyListArgs.Set("initial-cluster-state", "existing")
Expand Down Expand Up @@ -519,7 +519,7 @@ func (e *Etcd) argsForControlPlane(ctx context.Context, r runtime.Runtime, spec
var initialCluster string

if e.Bootstrap {
initialCluster = fmt.Sprintf("%s=%s", spec.Name, formatEtcdURLs(spec.AdvertisedAddresses, constants.EtcdPeerPort))
initialCluster = formatClusterURLs(spec.Name, getEtcdURLs(spec.AdvertisedAddresses, constants.EtcdPeerPort))
} else {
initialCluster, e.learnerMemberID, err = buildInitialCluster(ctx, r, spec.Name, getEtcdURLs(spec.AdvertisedAddresses, constants.EtcdPeerPort))
if err != nil {
Expand Down Expand Up @@ -714,3 +714,9 @@ func getEtcdURLs(addrs []netip.Addr, port int) []string {
func formatEtcdURLs(addrs []netip.Addr, port int) string {
return strings.Join(getEtcdURLs(addrs, port), ",")
}

func formatClusterURLs(name string, urls []string) string {
return strings.Join(slices.Map(urls, func(url string) string {
return fmt.Sprintf("%s=%s", name, url)
}), ",")
}

0 comments on commit 00e52ae

Please sign in to comment.