From 2e49d94fad75b3a240788ddb2a4a83f4464f64da Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Mon, 3 Mar 2025 18:42:00 +1000 Subject: [PATCH] fix: deduplicate discovered machine IPs --- internal/machine/machine.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/machine/machine.go b/internal/machine/machine.go index 492a7be4..01f1bce5 100644 --- a/internal/machine/machine.go +++ b/internal/machine/machine.go @@ -19,6 +19,7 @@ import ( "os" "os/user" "path/filepath" + "slices" "strconv" "uncloud/internal/corrosion" "uncloud/internal/docker" @@ -541,7 +542,9 @@ func (m *Machine) InitCluster(ctx context.Context, req *pb.InitClusterRequest) ( publicIP, pubIPErr := network.GetPublicIP() // Ignore the error if failed to get the public IP using API services. if pubIPErr == nil { - ips = append(ips, publicIP) + if !slices.Contains(ips, publicIP) { + ips = append(ips, publicIP) + } } endpoints := make([]*pb.IPPort, len(ips)) for i, addr := range ips {