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

Add VM LiveMigratable Condition to KubevirtMachine #291

Merged

Conversation

orenc1
Copy link
Contributor

@orenc1 orenc1 commented Jul 14, 2024

What this PR does / why we need it:
Virtual Machines serving as guest cluster nodes can be live migrated, this is beneficial in case of infra cluster nodes maintainance or mulfunction,
requiring the Virtual Machines to be migrated to another node.
This PR introduces the "VMLiveMigratable" condition to KubevirtMachine, and it takes that value as-is from the underlying VirtualMachine instance.
Then, consumers of cluster-api-provider-kubevirt could make use of it and buble that information up to the end user.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Release notes:

add VMLiveMigratable Condition to KubevirtMachine

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 14, 2024
@k8s-ci-robot k8s-ci-robot requested review from qinqon and timothysc July 14, 2024 07:28
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 14, 2024
@orenc1
Copy link
Contributor Author

orenc1 commented Jul 14, 2024

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

@orenc1: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@orenc1 orenc1 force-pushed the add_vm_live_migratable_condition branch from 0ef59c2 to 1bd1cba Compare July 14, 2024 09:19
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 14, 2024
@orenc1 orenc1 changed the title [WIP] Add vm live migratable condition Add VM LiveMigratable Condition to KubevirtMachine Jul 14, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 14, 2024
@orenc1 orenc1 force-pushed the add_vm_live_migratable_condition branch from 1bd1cba to dcf7114 Compare July 14, 2024 09:21
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 14, 2024
@orenc1 orenc1 force-pushed the add_vm_live_migratable_condition branch from dcf7114 to e7d006a Compare July 14, 2024 14:04
@nunnatsa
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Jul 14, 2024
@coveralls
Copy link

coveralls commented Jul 14, 2024

Pull Request Test Coverage Report for Build 9975585266

Details

  • 25 of 42 (59.52%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 59.245%

Changes Missing Coverage Covered Lines Changed/Added Lines %
controllers/kubevirtmachine_controller.go 9 13 69.23%
pkg/kubevirt/machine.go 0 13 0.0%
Totals Coverage Status
Change from base Build 9421398414: -0.04%
Covered Lines: 1570
Relevant Lines: 2650

💛 - Coveralls

Copy link
Contributor

@nunnatsa nunnatsa left a comment

Choose a reason for hiding this comment

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

Added a few comments

conditions.MarkTrue(ctx.KubevirtMachine, infrav1.VMLiveMigratableCondition)
} else {
conditions.MarkFalse(ctx.KubevirtMachine, infrav1.VMLiveMigratableCondition, infrav1.VMNotLiveMigratableReason, clusterv1.ConditionSeverityInfo,
fmt.Sprintf("%s is not a live migratable machine", ctx.KubevirtMachine.Name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we bubble up the actual reason from the vmi?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, good point.
do we want only the reason, or also the message text from the VM condition?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say, message is more important here. please add the underline message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. the message is now being shown if the condition status is false.

"sigs.k8s.io/controller-runtime/pkg/client"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

. "sigs.k8s.io/cluster-api-provider-kubevirt/pkg/infracluster"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid dot import

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was before my change.
probably it moved by running make generate

Comment on lines 232 to 237
for _, cond := range m.vmiInstance.Status.Conditions {
if cond.Type == kubevirtv1.VirtualMachineInstanceIsMigratable &&
cond.Status == corev1.ConditionTrue {
return true
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

use conditions.IsTrue()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is not possible to use conditions.IsTrue(...) on VirtualMachineInstance because it does not implement the Getter method GetConditions() clusterv1.Conditions

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, custom conditions. grrr!

Comment on lines 257 to 258
func (m *Machine) IsLiveMigratable() bool {
return m.hasLiveMigratableCondition()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this wrap over hasLiveMigratableCondition? we can just move the logic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i did it in a similar fashion as done with the IsReady() interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, the logic has been moved to IsLiveMigratable() and it is now returning two more values (message and error). m.hasLiveMigratableCondition() has been removed.

@orenc1 orenc1 force-pushed the add_vm_live_migratable_condition branch 3 times, most recently from c398c0c to feaa795 Compare July 15, 2024 15:12
Comment on lines 246 to 254
for _, cond := range m.vmiInstance.Status.Conditions {
if cond.Type == kubevirtv1.VirtualMachineInstanceIsMigratable {
if cond.Status == corev1.ConditionTrue {
return true, "", nil
} else {
return false, cond.Message, nil
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

in addition to the message, would it also make sense to pass the original "Reason" back from the VMI condition and copy it to the KubeVirtMachine reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. the reason from the VMI condition is now being copied to the KubevirtMachine condition as-is.

@orenc1 orenc1 force-pushed the add_vm_live_migratable_condition branch 2 times, most recently from 7cf12df to 0e6cc11 Compare July 17, 2024 13:15
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 17, 2024
@orenc1 orenc1 force-pushed the add_vm_live_migratable_condition branch from 0e6cc11 to c279635 Compare July 17, 2024 13:15
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 17, 2024
Virtual Machines serving as guest cluster nodes can be live migrated, this is beneficial in case of infra cluster nodes maintainance or mulfunction,
requiring the Virtual Machines to be migrated to another node.
This PR introduces the "VMLiveMigratable" condition to KubevirtMachine, and it takes that value as-is from the underlying VirtualMachine instance.
Then, consumers of cluster-api-provider-kubevirt could make use of it and buble that information up to the end user.

Signed-off-by: Oren Cohen <[email protected]>
@orenc1 orenc1 force-pushed the add_vm_live_migratable_condition branch from c279635 to 0ce6061 Compare July 17, 2024 13:55
Copy link
Contributor

@davidvossel davidvossel left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 17, 2024
Copy link
Contributor

@nunnatsa nunnatsa left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 21, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidvossel, nunnatsa, orenc1

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [davidvossel,nunnatsa]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 8c78f30 into kubernetes-sigs:main Jul 21, 2024
13 of 15 checks passed
@orenc1 orenc1 deleted the add_vm_live_migratable_condition branch July 22, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants