-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add VM LiveMigratable Condition to KubevirtMachine #291
Conversation
/ok-to-test |
@orenc1: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
0ef59c2
to
1bd1cba
Compare
1bd1cba
to
dcf7114
Compare
dcf7114
to
e7d006a
Compare
/ok-to-test |
Pull Request Test Coverage Report for Build 9975585266Details
💛 - Coveralls |
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid dot import
There was a problem hiding this comment.
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
pkg/kubevirt/machine.go
Outdated
for _, cond := range m.vmiInstance.Status.Conditions { | ||
if cond.Type == kubevirtv1.VirtualMachineInstanceIsMigratable && | ||
cond.Status == corev1.ConditionTrue { | ||
return true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use conditions.IsTrue()
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, custom conditions. grrr!
pkg/kubevirt/machine.go
Outdated
func (m *Machine) IsLiveMigratable() bool { | ||
return m.hasLiveMigratableCondition() | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
c398c0c
to
feaa795
Compare
pkg/kubevirt/machine.go
Outdated
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 | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
7cf12df
to
0e6cc11
Compare
0e6cc11
to
c279635
Compare
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]>
c279635
to
0ce6061
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[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:
Approvers can indicate their approval by writing |
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: