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

Support to set a specify hostName for a CloneVM #10834

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

Conversation

matthewei
Copy link
Contributor

@matthewei matthewei commented Dec 5, 2023

What this PR does / why we need it:

Sometimes we want to set hostname for CloneVM just as the VM which can be set hostname.

we can realize this function based on the following

kind: VirtualMachineClone
apiVersion: "clone.kubevirt.io/v1alpha1"
metadata:
  name: testclone
spec:
  # target definitions hostname
  hostname: vmclone

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 #10742

Special notes for your reviewer:

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note:

Add the possibility to specify vm target hostname during clone

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: no Indicates the PR's author has not DCO signed all their commits. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Dec 5, 2023
@kubevirt-bot kubevirt-bot added size/M needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 5, 2023
@kubevirt-bot
Copy link
Contributor

Hi @matthewei. Thanks for your PR.

I'm waiting for a kubevirt member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign alonakaplan for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@matthewei
Copy link
Contributor Author

I forget to add e2e test and unit-test. I will add it soon.

@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. and removed dco-signoff: no Indicates the PR's author has not DCO signed all their commits. labels Dec 5, 2023
@alaypatel07
Copy link
Contributor

/cc for api change review

@kubevirt-bot
Copy link
Contributor

@alaypatel07: GitHub didn't allow me to request PR reviews from the following users: change, review, for.

Note that only kubevirt members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc for api change review

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.

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 7, 2023
@xpivarc
Copy link
Member

xpivarc commented Dec 7, 2023

/cc @alaypatel07

Copy link
Contributor

@alaypatel07 alaypatel07 left a comment

Choose a reason for hiding this comment

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

In terms of API, the changes look good, added couple of nits. Pending tests, this would be a good add to vmclone, thanks @matthewei

api/openapi-spec/swagger.json Outdated Show resolved Hide resolved
@kubevirt-bot kubevirt-bot added dco-signoff: no Indicates the PR's author has not DCO signed all their commits. size/L and removed dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/M labels Dec 26, 2023
@matthewei matthewei force-pushed the CloneVMSupportSetHostname branch 2 times, most recently from 543a3a7 to 157119d Compare December 26, 2023 04:43
Copy link
Contributor Author

@matthewei matthewei left a comment

Choose a reason for hiding this comment

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

Plese help me to review this PR

api/openapi-spec/swagger.json Outdated Show resolved Hide resolved
pkg/virt-controller/watch/clone/clone_test.go Show resolved Hide resolved
pkg/virt-controller/watch/clone/vm-target.go Outdated Show resolved Hide resolved
tests/clone_test.go Outdated Show resolved Hide resolved
tests/clone_test.go Outdated Show resolved Hide resolved
tests/clone_test.go Outdated Show resolved Hide resolved
@matthewei
Copy link
Contributor Author

@fossedihelm Hi, please help me review this PR. Many thanks!

@matthewei
Copy link
Contributor Author

/retest

@kubevirt-bot
Copy link
Contributor

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

In response to this:

/retest

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.

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.

Thanks a lot @matthewei!
Almost there! :) left some small comments.

Great job and thanks for your patience!

@@ -65,7 +65,9 @@ type VirtualMachineCloneSpec struct {
// inspecting status "TargetName" field below.
// +optional
Target *corev1.TypedLocalObjectReference `json:"target,omitempty"`

// Specifies the hostname of the clone vmi.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Specifies the hostname of the clone vmi.
// Specifies the hostname of the clone vm.

Small but important correction: clones operate on the VM level, not the VMI level

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

@@ -108,6 +110,10 @@ func (admitter *VirtualMachineCloneAdmitter) Admit(ar *admissionv1.AdmissionRevi
causes = append(causes, newCauses...)
}

if newCauses := validateCloneHostNameNotConformingToDNSLabelRules(vmClone); newCauses != 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 the future we may add more general validations to hostname

Suggested change
if newCauses := validateCloneHostNameNotConformingToDNSLabelRules(vmClone); newCauses != nil {
if newCauses := validateCloneHostName(vmClone); newCauses != nil {

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

@iholder101
Copy link
Contributor

Thanks a lot @matthewei!
/test all

@iholder101
Copy link
Contributor

@matthewei There are lane failures. For example, the unit tests lane says:

pkg/virt-api/webhooks/validating-webhook/admitters/vmclone-admitter_test.go:409:28: cannot use "test" (untyped string constant) as *string value in assignment
pkg/virt-api/webhooks/validating-webhook/admitters/vmclone-admitter_test.go:414:28: cannot use "test+bad" (untyped string constant) as *string value in assignment

Can you please to build and test locally? To do so:

  • Run make
  • Run make test
  • Optional: change Describe to FDescribe here and run make cluster-up && make cluster-sync && make functest
    var _ = Describe("[Serial]VirtualMachineClone Tests", Serial, func() {

@matthewei
Copy link
Contributor Author

@matthewei There are lane failures. For example, the unit tests lane says:

pkg/virt-api/webhooks/validating-webhook/admitters/vmclone-admitter_test.go:409:28: cannot use "test" (untyped string constant) as *string value in assignment
pkg/virt-api/webhooks/validating-webhook/admitters/vmclone-admitter_test.go:414:28: cannot use "test+bad" (untyped string constant) as *string value in assignment

Can you please to build and test locally? To do so:

  • Run make
  • Run make test
  • Optional: change Describe to FDescribe here and run make cluster-up && make cluster-sync && make functest
    var _ = Describe("[Serial]VirtualMachineClone Tests", Serial, func() {

OK, will do it

@matthewei
Copy link
Contributor Author

@matthewei There are lane failures. For example, the unit tests lane says:

pkg/virt-api/webhooks/validating-webhook/admitters/vmclone-admitter_test.go:409:28: cannot use "test" (untyped string constant) as *string value in assignment
pkg/virt-api/webhooks/validating-webhook/admitters/vmclone-admitter_test.go:414:28: cannot use "test+bad" (untyped string constant) as *string value in assignment

Can you please to build and test locally? To do so:

  • Run make
  • Run make test
  • Optional: change Describe to FDescribe here and run make cluster-up && make cluster-sync && make functest
    var _ = Describe("[Serial]VirtualMachineClone Tests", Serial, func() {

Hi, I got the following errors,Could you give me a hand?
image

@iholder101
Copy link
Contributor

@matthewei you probably need to deploy storage to the cluster. Try:

> export KUBEVIRT_STORAGE=rook-ceph-default
> make cluster-up && make cluster-sync

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 28, 2024
@matthewei
Copy link
Contributor Author

make cluster-up && make cluster-sync

ok , Come back and ready going on it

@kubevirt-bot kubevirt-bot added size/M and removed size/L needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 5, 2024
@matthewei matthewei force-pushed the CloneVMSupportSetHostname branch 2 times, most recently from 0a6da2b to 58afafd Compare June 5, 2024 07:21
@kubevirt-bot kubevirt-bot added size/L and removed size/M labels Jun 5, 2024
Signed-off-by: shenwei <shenwei_yewu@cmss.chinamobile.com>
@matthewei
Copy link
Contributor Author

@iholder101 If I want to exec the command test all. How can i realize it?

@iholder101
Copy link
Contributor

iholder101 commented Jun 9, 2024

@iholder101 If I want to exec the command test all. How can i realize it?

In order to do so you need to be a community member.
Let me help you with that.

/test pull-kubevirt-build
/test pull-kubevirt-unit-test
/test pull-kubevirt-e2e-k8s-1.30-sig-compute
/test pull-kubevirt-e2e-k8s-1.30-sig-compute

I also suggest to try and building, running unit tests, and preferably running some functional tests locally before triggering CI.

@kubevirt-bot
Copy link
Contributor

@matthewei: 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.29-sig-compute 4a1d770 link true /test pull-kubevirt-e2e-k8s-1.29-sig-compute
pull-kubevirt-unit-test-arm64 6c960f4 link false /test pull-kubevirt-unit-test-arm64
pull-kubevirt-code-lint 6c960f4 link true /test pull-kubevirt-code-lint
pull-kubevirt-goveralls 6c960f4 link false /test pull-kubevirt-goveralls
pull-kubevirt-unit-test 1aad167 link true /test pull-kubevirt-unit-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. I understand the commands that are listed here.

@kubevirt-bot
Copy link
Contributor

PR needs rebase.

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.

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/buildsystem Denotes an issue or PR that relates to changes in the build system. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support to set a specify hostName for a CloneVM
8 participants