Skip to content

Commit

Permalink
refactor(vmip): add log message when VirtualMachineIPAddressLease is …
Browse files Browse the repository at this point in the history
…bound to another

Signed-off-by: Dmitry Lopatin <[email protected]>
  • Loading branch information
LopatinDmitr committed Aug 16, 2024
1 parent 40c6496 commit 04149fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ func (h IPLeaseHandler) Handle(ctx context.Context, state state.VMIPState) (reco
log.Info("Lease is released: set binding")

if lease.Spec.VirtualMachineIPAddressRef.Namespace != vmip.Namespace {
msg := fmt.Sprintf("the selected VirtualMachineIP lease belongs to a different namespace: %s", lease.Spec.VirtualMachineIPAddressRef.Namespace)
log.Error(msg)
h.recorder.Event(vmip, corev1.EventTypeWarning, vmipcondition.VirtualMachineIPAddressLeaseNotFound, msg)
log.Warn(fmt.Sprintf("The VirtualMachineIPLease belongs to a different namespace: %s", lease.Spec.VirtualMachineIPAddressRef.Namespace))
h.recorder.Event(vmip, corev1.EventTypeWarning, vmipcondition.VirtualMachineIPAddressLeaseAlready, "The VirtualMachineIPLease belongs to a different namespace")

return reconcile.Result{}, nil
}

Expand Down Expand Up @@ -150,7 +150,7 @@ func (h IPLeaseHandler) createNewLease(ctx context.Context, state state.VMIPStat
vmipStatus.Phase = virtv2.VirtualMachineIPAddressPhasePending
mgr.Update(conditionBound.Status(metav1.ConditionFalse).
Reason(vmipcondition.VirtualMachineIPAddressLeaseAlready).
Message(fmt.Sprintf("VirtualMachineIPAddressLease %s is bound to another VirtualMachineIP",
Message(fmt.Sprintf("VirtualMachineIPAddressLease %s is bound to another VirtualMachineIPAddress",
common.IpToLeaseName(vmipStatus.Address))).
Condition())
h.recorder.Event(vmip, corev1.EventTypeWarning, vmipcondition.VirtualMachineIPAddressLeaseAlready, msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (h *LifecycleHandler) Handle(ctx context.Context, state state.VMIPState) (r
mgr.Update(conditionBound.Status(metav1.ConditionFalse).
Reason(vmipcondition.VirtualMachineIPAddressLeaseNotReady).
Message(fmt.Sprintf("VirtualMachineIPAddressLease %s is not ready",
common.IpToLeaseName(vmipStatus.Address))).
lease.Name)).
Condition())
}
}
Expand Down

0 comments on commit 04149fb

Please sign in to comment.