Skip to content

Commit 8dd3361

Browse files
damdosmira
authored andcommitted
fix: fallback to ExternalIP for boostrap if no InternalIP is found
Try finding any ExternalIPs addresses when bootstrapping a cluster if no InternalIPs address is found for the machine. Signed-off-by: Damiano Donati <[email protected]> Signed-off-by: Artem Chernyshev <[email protected]> (cherry picked from commit f3ff7ad)
1 parent 86f043f commit 8dd3361

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

controllers/taloscontrolplane_controller.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ func (r *TalosControlPlaneReconciler) bootstrapCluster(ctx context.Context, tcp
407407
for _, machine := range machines {
408408
found := false
409409

410+
// Prefer finding an InternalIP address for the machine first.
410411
for _, addr := range machine.Status.Addresses {
411412
if addr.Type == clusterv1.MachineInternalIP {
412413
addresses = append(addresses, addr.Address)
@@ -417,8 +418,24 @@ func (r *TalosControlPlaneReconciler) bootstrapCluster(ctx context.Context, tcp
417418
}
418419
}
419420

421+
if found {
422+
continue
423+
}
424+
425+
// Fallback to finding an ExternalIP address for the machine
426+
// if no InternalIP is found.
427+
for _, addr := range machine.Status.Addresses {
428+
if addr.Type == clusterv1.MachineExternalIP {
429+
addresses = append(addresses, addr.Address)
430+
431+
found = true
432+
433+
break
434+
}
435+
}
436+
420437
if !found {
421-
return fmt.Errorf("machine %q doesn't have an InternalIP address yet", machine.Name)
438+
return fmt.Errorf("machine %q doesn't have an any InternalIP or ExternalIP address yet", machine.Name)
422439
}
423440
}
424441

0 commit comments

Comments
 (0)