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

Introduce generated client for core/v1 resources #11297

Merged
merged 7 commits into from Mar 12, 2024

Conversation

fossedihelm
Copy link
Contributor

@fossedihelm fossedihelm commented Feb 19, 2024

What this PR does

Before this PR:
We are using the generated client for some resources, such as clone or migration, while we are using
the custom, manually maintained, for the core resources (VM, VMI...)

After this PR:
Convert using the generated client instead of the custom one.
This is the path will be followed:

  1. Introduction of the generated client.
  2. Redirect common api calls to the generated client
    leaving the custom struct as extended wrapper.
  3. Drop the custom wrapper structs, moving to the generated
    resources only.

NB: This PR covers just the first two steps, since otherwise the changes will result
too big.
*

Fixes #

Why we need it and why it was done in this way

The generated client has the advantage that the various methods will have the same standard signature. Currently, the method's signature between Get/Create/Update etc.. are different between VM/VMI/etc..:

  • sometimes a context is required, sometimes no
  • sometimes the options are required, sometimes no
  • sometimes a pointer is used as options, sometimes directly the struct

Also, alongside the generated client, the client-gen command generates the fakeclient that can be used in unit tests.
The fakeclient has the benefit, in unit tests, of simulating the real client and recording the changes, getting rid of mocking API requests (that can create misalignment to the reality) e.g. #10908

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

NONE

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XXL labels Feb 19, 2024
@fossedihelm
Copy link
Contributor Author

/test all

@fossedihelm
Copy link
Contributor Author

/test pull-kubevirt-verify-go-mod

@fossedihelm
Copy link
Contributor Author

/test all

@fossedihelm fossedihelm marked this pull request as ready for review February 20, 2024 09:14
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 20, 2024
@aburdenthehand
Copy link
Contributor

/cc @alaypatel07

@Barakmor1
Copy link
Member

/cc

@Barakmor1
Copy link
Member

Barakmor1 commented Feb 26, 2024

Hello @fossedihelm ,

I noticed in the commit message that you’ve outlined the task as consisting of three steps. In your commits, you’ve labeled them as “step 1” and “step 2.” However, I’m a bit confused because there seems to be a third step mentioned, but I only see two steps addressed in the commits. Could you please clarify if the second and third steps are included within the same commits, or am i missing something?

@fossedihelm
Copy link
Contributor Author

Hello @fossedihelm ,

I noticed in the commit message that you’ve outlined the task as consisting of three steps. In your commits, you’ve labeled them as “step 1” and “step 2.” However, I’m a bit confused because there seems to be a third step mentioned, but I only see two steps addressed in the commits. Could you please clarify if the second and third steps are included within the same commits, or am i missing something?

Hey @Barakmor1 sorry about that, as I mentioned in the PR description, this PR only covers the first two steps (Now I have highlighted that part).
I thought having the full overview of the journey in the commits was good. Hope this helps. Thank you again!

@Barakmor1
Copy link
Member

Hello @fossedihelm ,
I noticed in the commit message that you’ve outlined the task as consisting of three steps. In your commits, you’ve labeled them as “step 1” and “step 2.” However, I’m a bit confused because there seems to be a third step mentioned, but I only see two steps addressed in the commits. Could you please clarify if the second and third steps are included within the same commits, or am i missing something?

Hey @Barakmor1 sorry about that, as I mentioned in the PR description, this PR only covers the first two steps (Now I have highlighted that part). I thought having the full overview of the journey in the commits was good. Hope this helps. Thank you again!

Thanks for clarifying

Comment on lines 151 to 111
func (v *migration) UpdateStatus(vmi *v1.VirtualMachineInstanceMigration) (result *v1.VirtualMachineInstanceMigration, err error) {
func (o *migration) UpdateStatus(vmi *v1.VirtualMachineInstanceMigration) (result *v1.VirtualMachineInstanceMigration, err error) {
result = &v1.VirtualMachineInstanceMigration{}
err = v.restClient.Put().
err = o.restClient.Put().
Name(vmi.ObjectMeta.Name).
Namespace(v.namespace).
Resource(v.resource).
Namespace(o.namespace).
Resource(o.resource).
SubResource("status").
Copy link
Member

Choose a reason for hiding this comment

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

I think you forgot to use o.VirtualMachineInstanceMigrationInterface.UpdateStatus 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.

Nice catch! You're right! Thanks for catching this! Done

@Barakmor1
Copy link
Member

I would also remove the 3 step from the commit message or at least mention that it will be handled in the future so it will be clear just from reading the commit messages.

Convert using the generated client instead of the custom one.
This is the path will be followed:
1. Introduction of the generated client.
2. Redirect common api calls to the generated client
 leaving the custom struct as extended wrapper.

This the step 1 of the conversion using the generated client.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
@fossedihelm
Copy link
Contributor Author

I would also remove the 3 step from the commit message or at least mention that it will be handled in the future so it will be clear just from reading the commit messages.

Thank you! I dropped the mention of the 3rd step in the commits.

@Barakmor1
Copy link
Member

Thank you !
/lgtm

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 7, 2024
Convert using the generated client instead of the custom one.
This is the path will be followed:
1. Introduction of the generated client.
2. Redirect common api calls to the generated client
 leaving the custom struct as extended wrapper.

This the step 2 for the VMI resource of the conversion
 using the generated client.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
@fossedihelm
Copy link
Contributor Author

Changes Addressed possible nil pointer reference.

Convert using the generated client instead of the custom one.
This is the path will be followed:
1. Introduction of the generated client.
2. Redirect common api calls to the generated client
 leaving the custom struct as extended wrapper.

This the step 2 for the VMIM resource of the conversion
 using the generated client.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Convert using the generated client instead of the custom one.
This is the path will be followed:
1. Introduction of the generated client.
2. Redirect common api calls to the generated client
 leaving the custom struct as extended wrapper.

This the step 2 for the VMIRS resource of the conversion
 using the generated client.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Convert using the generated client instead of the custom one.
This is the path will be followed:
1. Introduction of the generated client.
2. Redirect common api calls to the generated client
 leaving the custom struct as extended wrapper.

This the step 2 for the VM resource of the conversion
 using the generated client.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Convert using the generated client instead of the custom one.
This is the path will be followed:
1. Introduction of the generated client.
2. Redirect common api calls to the generated client
 leaving the custom struct as extended wrapper.

This the step 2 for the KV resource of the conversion
 using the generated client.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Convert using the generated client instead of the custom one.
This is the path will be followed:
1. Introduction of the generated client.
2. Redirect common api calls to the generated client
 leaving the custom struct as extended wrapper.

This the step 2 for the VMIP resource of the conversion
 using the generated client.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
@fossedihelm
Copy link
Contributor Author

Changes:

  • Fixed dirty git tree ci failures
  • Convert PatchStatus implementation to Patch with subresources
    @xpivarc PTAL Thanks

@xpivarc
Copy link
Member

xpivarc commented Mar 8, 2024

/hold cancel

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 8, 2024
@fossedihelm
Copy link
Contributor Author

@Barakmor1 PTAL 🙂

@Barakmor1
Copy link
Member

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 11, 2024
@kubevirt-commenter-bot
Copy link

Required labels detected, running phase 2 presubmits:
/test pull-kubevirt-e2e-windows2016
/test pull-kubevirt-e2e-kind-1.27-vgpu
/test pull-kubevirt-e2e-kind-sriov
/test pull-kubevirt-e2e-k8s-1.29-ipv6-sig-network
/test pull-kubevirt-e2e-k8s-1.27-sig-network
/test pull-kubevirt-e2e-k8s-1.27-sig-storage
/test pull-kubevirt-e2e-k8s-1.27-sig-compute
/test pull-kubevirt-e2e-k8s-1.27-sig-operator
/test pull-kubevirt-e2e-k8s-1.28-sig-network
/test pull-kubevirt-e2e-k8s-1.28-sig-storage
/test pull-kubevirt-e2e-k8s-1.28-sig-compute
/test pull-kubevirt-e2e-k8s-1.28-sig-operator

@fossedihelm
Copy link
Contributor Author

/cherrypick release-1.2

@kubevirt-bot
Copy link
Contributor

@fossedihelm: new pull request created: #11772

In response to this:

/cherrypick release-1.2

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. release-note-none Denotes a PR that doesn't merit a release note. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants