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 Virtual Machine name label to virt-launcher pod #7102

Merged

Conversation

machadovilaca
Copy link
Member

@machadovilaca machadovilaca commented Jan 18, 2022

Adding this label will allow monitoring systems to correlate the virt-launcher pods running the VMs and the VMs themselves.

We should guarantee that if the user is not using an internal template with predefined labels, we will still ensure we have this information

/cc @sradco

Signed-off-by: João Vilaça jvilaca@redhat.com

What this PR does / why we need it:

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

Special notes for your reviewer:

Release note:

Add Virtual Machine name label to virt-launcher pod

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/M labels Jan 18, 2022
@sradco
Copy link
Contributor

sradco commented Jan 18, 2022

/retest

@orelmisan
Copy link
Member

Hi @machadovilaca, can you please explain the motivation behind this change? (in the PR description)

@machadovilaca machadovilaca force-pushed the add-vm-name-label-to-virt-launcher branch from c0551a7 to 66a2ba9 Compare January 19, 2022 10:19
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2022
@machadovilaca machadovilaca force-pushed the add-vm-name-label-to-virt-launcher branch from 66a2ba9 to b053f39 Compare January 19, 2022 10:21
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2022
@machadovilaca
Copy link
Member Author

@orelmisan description updated

@orelmisan
Copy link
Member

orelmisan commented Jan 19, 2022

@orelmisan description updated

@machadovilaca Thank you!

Copy link
Contributor

@iholder101 iholder101 left a comment

Choose a reason for hiding this comment

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

I like this idea a lot. Thanks, great job!

Expect(len(pod.Spec.Containers)).To(Equal(1))
vmNameLabel, ok := pod.Labels[v1.VirtualMachineNameLabel]
Expect(ok).To(BeTrue())
Expect(vmNameLabel).To(Equal("testvmi"))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I would use vmi.Name(): Expect(vmNameLabel).To(Equal(vmi.Name()))

Copy link
Member Author

Choose a reason for hiding this comment

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

updated


pod, err := svc.RenderLaunchManifest(&vmi)
Expect(err).ToNot(HaveOccurred())
Expect(len(pod.Spec.Containers)).To(Equal(1))
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 this line is redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

Comment on lines 3241 to 3246
pod, err := svc.RenderLaunchManifest(&vmi)
Expect(err).ToNot(HaveOccurred())
Expect(len(pod.Spec.Containers)).To(Equal(1))
vmNameLabel, ok := pod.Labels[v1.VirtualMachineNameLabel]
Expect(ok).To(BeTrue())
Expect(vmNameLabel).To(Equal("testvmi"))
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@@ -3200,6 +3203,49 @@ var _ = Describe("Template", func() {
Expect(pod.Spec.Containers[0].Resources.Requests.Memory().Value()).To(Equal(expectedMemory.Value()))
})
})

Context("with Virtual Machine name label in the template", func() {
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 that using "template" in here is confusing and out of context.
Maybe "with Virtual Machine name label annotation" would be better.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed in the template

})
})

Context("without Virtual Machine name label in the template", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Member Author

Choose a reason for hiding this comment

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

removed in the template

@machadovilaca machadovilaca force-pushed the add-vm-name-label-to-virt-launcher branch from b053f39 to 2504610 Compare January 20, 2022 11:34
Copy link
Contributor

@iholder101 iholder101 left a comment

Choose a reason for hiding this comment

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

Great job!
/lgtm

One nit below, you don't have to use it - up to you.


pod, err := svc.RenderLaunchManifest(&vmi)
Expect(err).ToNot(HaveOccurred())
Expect(len(pod.Spec.Containers)).To(Equal(1))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: You can change it to Expect(pod.Spec.Containers).To(HaveLen(1))

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2022
@machadovilaca machadovilaca force-pushed the add-vm-name-label-to-virt-launcher branch from 2504610 to 3f59394 Compare January 20, 2022 12:43
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2022
@sradco
Copy link
Contributor

sradco commented Jan 20, 2022

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2022
@machadovilaca
Copy link
Member Author

/retest

3 similar comments
@sradco
Copy link
Contributor

sradco commented Jan 23, 2022

/retest

@sradco
Copy link
Contributor

sradco commented Jan 24, 2022

/retest

@sradco
Copy link
Contributor

sradco commented Jan 31, 2022

/retest

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2022
@machadovilaca
Copy link
Member Author

/retest

@sradco
Copy link
Contributor

sradco commented Feb 3, 2022

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2022
@machadovilaca
Copy link
Member Author

/assign @stu-gott

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2022
Signed-off-by: João Vilaça <jvilaca@redhat.com>
Signed-off-by: João Vilaça <jvilaca@redhat.com>
@machadovilaca machadovilaca force-pushed the add-vm-name-label-to-virt-launcher branch from 39b3e9b to a11c1e2 Compare February 22, 2022 11:26
@iholder101
Copy link
Contributor

/lgtm
Thanks!

@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2022
@iholder101
Copy link
Contributor

/ok-to-test

@kubevirt-bot kubevirt-bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Feb 23, 2022
@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Feb 23, 2022

@machadovilaca: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-e2e-k8s-1.20-cgroupsv2 b053f39 link true /test pull-kubevirt-e2e-k8s-1.20-cgroupsv2
pull-kubevirt-e2e-k8s-1.20-sig-compute-nonroot b053f39 link true /test pull-kubevirt-e2e-k8s-1.20-sig-compute-nonroot

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/test-infra repository. I understand the commands that are listed here.

@machadovilaca
Copy link
Member Author

/retest

Copy link
Member

@stu-gott stu-gott left a comment

Choose a reason for hiding this comment

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

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: stu-gott

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 23, 2022
@kubevirt-bot kubevirt-bot merged commit 88ef459 into kubevirt:main Feb 23, 2022
@machadovilaca machadovilaca deleted the add-vm-name-label-to-virt-launcher branch February 23, 2022 20:14
@machadovilaca
Copy link
Member Author

/cherrypick release-0.49
/cherrypick release-0.50

@kubevirt-bot
Copy link
Contributor

@machadovilaca: #7102 failed to apply on top of branch "release-0.49":

Applying: Add Virtual Machine name label to virt-launcher pod
Using index info to reconstruct a base tree...
M	pkg/virt-controller/services/template.go
M	pkg/virt-controller/services/template_test.go
M	staging/src/kubevirt.io/api/core/v1/types.go
Falling back to patching base and 3-way merge...
Auto-merging staging/src/kubevirt.io/api/core/v1/types.go
CONFLICT (content): Merge conflict in staging/src/kubevirt.io/api/core/v1/types.go
Auto-merging pkg/virt-controller/services/template_test.go
Auto-merging pkg/virt-controller/services/template.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add Virtual Machine name label to virt-launcher pod
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherrypick release-0.49
/cherrypick release-0.50

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/test-infra repository.

@machadovilaca
Copy link
Member Author

/cherrypick release-0.50

@kubevirt-bot
Copy link
Contributor

@machadovilaca: #7102 failed to apply on top of branch "release-0.50":

Applying: Add Virtual Machine name label to virt-launcher pod
Using index info to reconstruct a base tree...
M	pkg/virt-controller/services/template.go
M	staging/src/kubevirt.io/api/core/v1/types.go
Falling back to patching base and 3-way merge...
Auto-merging staging/src/kubevirt.io/api/core/v1/types.go
CONFLICT (content): Merge conflict in staging/src/kubevirt.io/api/core/v1/types.go
Auto-merging pkg/virt-controller/services/template.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add Virtual Machine name label to virt-launcher pod
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherrypick release-0.50

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/test-infra repository.

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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants