Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vmip): add new events #645

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat(vmip): add new events #645

wants to merge 1 commit into from

Conversation

eofff
Copy link
Contributor

@eofff eofff commented Jan 20, 2025

Description

Why do we need it, and what problem does it solve?

What is the expected result?

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

@eofff eofff self-assigned this Jan 20, 2025
@eofff eofff requested review from Isteb4k and hardcoretime January 20, 2025 14:09
@eofff eofff marked this pull request as ready for review January 20, 2025 14:10
add
Signed-off-by: Valeriy Khorunzhin <[email protected]>
@eofff eofff force-pushed the feat/vmip/add-events branch from 6cf5250 to 8cddac6 Compare January 20, 2025 14:11
@@ -144,14 +144,18 @@ func (h IPLeaseHandler) createNewLease(ctx context.Context, state state.VMIPStat
Reason(vmipcondition.VirtualMachineIPAddressIsOutOfTheValidRange).
Message(fmt.Sprintf("The requested address %s is out of the valid range",
vmip.Spec.StaticIP))
h.recorder.Event(vmip, corev1.EventTypeWarning, vmipcondition.VirtualMachineIPAddressIsOutOfTheValidRange.String(), msg)
h.recorder.Eventf(vmip, corev1.EventTypeWarning, virtv2.ReasonVMIPLeaseBoundFailed, "The requested address %s is out of the valid range", vmip.Spec.StaticIP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use variable "msg" because this message is identical with text in the "Message" from line 145.

h.recorder.Event(vmip, corev1.EventTypeWarning, vmipcondition.VirtualMachineIPAddressLeaseAlreadyExists.String(), msg)
h.recorder.Eventf(
vmip, corev1.EventTypeWarning, virtv2.ReasonVMIPLeaseBoundFailed,
"VirtualMachineIPAddressLease %s is bound to another VirtualMachineIPAddress",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same situation with identical message.

// ReasonVMIPVMAttached is event reason that VMIP attached to VM
ReasonVMIPVMAttached = "VMIPVMAttached"
// ReasonVMIPVMDetached is event reason that VMIP not attached to VM
ReasonVMIPVMDetached = "VMIPVMDetached"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "NotAttached" seems better. "Detached" sounds like VMIP was attached to VM and now is detached.

@@ -104,6 +111,7 @@ func (h *LifecycleHandler) Handle(ctx context.Context, state state.VMIPState) (r
vmipStatus.VirtualMachine = vm.Name
conditionAttach.Status(metav1.ConditionTrue).
Reason(vmipcondition.Attached)
h.recorder.Eventf(vmip, corev1.EventTypeNormal, virtv2.ReasonVMIPVMAttached, "VMIP is attached to %q/%q", vm.Namespace, vm.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use abbreviations in messages for user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants