Skip to content

Commit c8158eb

Browse files
authored
Merge pull request kubernetes-sigs#265 from davidvossel/stable-ip-v1
Don't mark machine ready=false when internalIP is known
2 parents 0c5adf9 + 2e531a9 commit c8158eb

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

controllers/kubevirtmachine_controller.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,17 @@ func (r *KubevirtMachineReconciler) reconcileNormal(ctx *context.MachineContext)
285285
ipAddress := externalMachine.Address()
286286
if ipAddress == "" {
287287
ctx.Logger.Info(fmt.Sprintf("KubevirtMachine %s: Got empty ipAddress, requeue", ctx.KubevirtMachine.Name))
288-
ctx.KubevirtMachine.Status.Ready = false
288+
// Only set readiness to false if we have never detected an internal IP for this machine.
289+
//
290+
// The internal ipAddress is sometimes detected via the qemu guest agent,
291+
// which will report an empty addr at some points when the guest is rebooting
292+
// or updating.
293+
//
294+
// This check prevents us from marking the infrastructure as not ready
295+
// when the internal guest might be rebooting or updating.
296+
if !machineHasKnownInternalIP(ctx.KubevirtMachine) {
297+
ctx.KubevirtMachine.Status.Ready = false
298+
}
289299
return ctrl.Result{RequeueAfter: 20 * time.Second}, nil
290300
}
291301

@@ -349,6 +359,15 @@ func (r *KubevirtMachineReconciler) reconcileNormal(ctx *context.MachineContext)
349359
return ctrl.Result{}, nil
350360
}
351361

362+
func machineHasKnownInternalIP(kubevirtMachine *infrav1.KubevirtMachine) bool {
363+
for _, addr := range kubevirtMachine.Status.Addresses {
364+
if addr.Type == clusterv1.MachineInternalIP && addr.Address != "" {
365+
return true
366+
}
367+
}
368+
return false
369+
}
370+
352371
func (r *KubevirtMachineReconciler) updateNodeProviderID(ctx *context.MachineContext) (ctrl.Result, error) {
353372
// If the provider ID is already updated on the Node, return
354373
if ctx.KubevirtMachine.Status.NodeUpdated {

0 commit comments

Comments
 (0)