Skip to content

Commit

Permalink
Merge pull request #265 from davidvossel/stable-ip-v1
Browse files Browse the repository at this point in the history
Don't mark machine ready=false when internalIP is known
  • Loading branch information
k8s-ci-robot committed Sep 14, 2023
2 parents 0c5adf9 + 2e531a9 commit c8158eb
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion controllers/kubevirtmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,17 @@ func (r *KubevirtMachineReconciler) reconcileNormal(ctx *context.MachineContext)
ipAddress := externalMachine.Address()
if ipAddress == "" {
ctx.Logger.Info(fmt.Sprintf("KubevirtMachine %s: Got empty ipAddress, requeue", ctx.KubevirtMachine.Name))
ctx.KubevirtMachine.Status.Ready = false
// Only set readiness to false if we have never detected an internal IP for this machine.
//
// The internal ipAddress is sometimes detected via the qemu guest agent,
// which will report an empty addr at some points when the guest is rebooting
// or updating.
//
// This check prevents us from marking the infrastructure as not ready
// when the internal guest might be rebooting or updating.
if !machineHasKnownInternalIP(ctx.KubevirtMachine) {
ctx.KubevirtMachine.Status.Ready = false
}
return ctrl.Result{RequeueAfter: 20 * time.Second}, nil
}

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

func machineHasKnownInternalIP(kubevirtMachine *infrav1.KubevirtMachine) bool {
for _, addr := range kubevirtMachine.Status.Addresses {
if addr.Type == clusterv1.MachineInternalIP && addr.Address != "" {
return true
}
}
return false
}

func (r *KubevirtMachineReconciler) updateNodeProviderID(ctx *context.MachineContext) (ctrl.Result, error) {
// If the provider ID is already updated on the Node, return
if ctx.KubevirtMachine.Status.NodeUpdated {
Expand Down

0 comments on commit c8158eb

Please sign in to comment.