Skip to content

Commit 28d3eab

Browse files
smiraUnix4ever
authored andcommitted
fix: skip nodes with empty hostname on etcd audit
When node is just joining the cluster, `etcd members` briefly returns a node with an empty hostname. If the member is deleted in this state, it breaks the etcd cluster build and breaks the cluster. Signed-off-by: Andrey Smirnov <[email protected]>
1 parent 377c408 commit 28d3eab

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

controllers/configs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ func (r *TalosControlPlaneReconciler) talosconfigForMachines(ctx context.Context
8686
}
8787
}
8888

89+
// we don't need to set endpoints in general here, as endpoints were already pre-populated by the CABPT controller
90+
// but we use the `machines` to _limit_ access to a specific machine in some places, and we need to be compatible
91+
// with talosconfigFromWorkloadCluster which doesn't rely on Machine's Addresses
92+
//
93+
// once we're done with Sidero and `init` nodes, we can switch to use `WithNodes` and proper Machine IPs
8994
return talosclient.New(ctx, talosclient.WithEndpoints(addrList...), talosclient.WithConfig(t))
9095
}
9196

controllers/etcd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ func (r *TalosControlPlaneReconciler) auditEtcd(ctx context.Context, tcp *contro
190190
// Only querying one CP node, so only 1 message should return.
191191
memberList := response.Messages[0]
192192

193-
if len(memberList.Members) == 0 {
194-
return nil
195-
}
196-
197193
// For each etcd member, look through the list of machines and see if noderef matches
198194
for _, member := range memberList.Members {
195+
if member.Hostname == "" {
196+
return fmt.Errorf("discovered etcd member with empty hostname: %s", member)
197+
}
198+
199199
present := false
200200
for _, machine := range machines {
201201
// break apart the noderef name in case it's an fqdn (like in AWS)

0 commit comments

Comments
 (0)