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

🐛 fix: webhook testEnv #4449

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

Conversation

mateusoliveira43
Copy link
Contributor

@mateusoliveira43 mateusoliveira43 commented Dec 27, 2024

Enable conversion webhooks for webhook suite_test.go envtest by using k8s.io/client-go/kubernetes/scheme instead of creating new scheme (this also already done in controller suite_test.go)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 27, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mateusoliveira43
Once this PR has been reviewed and has the lgtm label, please assign varshaprasad96 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

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 27, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @mateusoliveira43. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Dec 27, 2024
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Hi @mateusoliveira43,

This one will require a safer approach and a deeper analysis to ensure that these changes are truly necessary and/or the best approach for the default scaffolds.

Currently, we have envtests implemented and everything is functioning correctly, as shown here:
cronjob_webhook_test.go

I don’t believe that webhook tests are heavily used by users at the moment, but that doesn’t seem to be the case for controllers. Additionally, we already have mocks with tests that are functioning correctly for controllers.

Also, we’ve never added the CRDInstallOptions option—it doesn’t seem to be required.

Could we raise an issue explaining why this change is necessary?
Could you provide more detailed information in the description here?

It would be helpful if you could let us know:

  • What you tried to do and what didn’t work as expected.
  • What challenges you faced and what you expected to see instead that led you to make each change.
    (For example, moving the AddSchemes, removing the import, and adding the optional spec for envtest.)

/hold until we have those details and ensure that each change is required/and or is the best approach for the default scaffolds.

Btw, thanks a lot for looking on that.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 28, 2024
@mateusoliveira43
Copy link
Contributor Author

@camilamacedo86 will undo change to CRDInstallOptions, the default value is what I am adding

// Scheme is used to determine if conversion webhooks should be enabled
// for a particular CRD / object.
//
// Conversion webhooks are going to be enabled if an object in the scheme
// implements Hub and Spoke conversions.
//
// If nil, scheme.Scheme is used.

Will add more info to PR description

@mateusoliveira43 mateusoliveira43 force-pushed the fix/webhook-test-suite-scheme branch 2 times, most recently from 0c36daf to d540c85 Compare December 30, 2024 17:01
// cfg is defined in this file globally.
cfg, err = testEnv.Start()
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

/*
Copy link
Member

Choose a reason for hiding this comment

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

Hi @mateusoliveira43

I think we can reduce the scope of this one
We can have a PR to add the schemas before start the envtest

Then, we can have a PR that propose we remove apimachineryruntime and use scheme.Scheme and explain why we want to do that

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

will open next one after that one merges

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 1, 2025
@camilamacedo86
Copy link
Member

HI @mateusoliveira43

Can you rebase it with the master and ensure that you have what was changed and why in the description?

Signed-off-by: Mateus Oliveira <[email protected]>
@mateusoliveira43 mateusoliveira43 force-pushed the fix/webhook-test-suite-scheme branch from d540c85 to f645d9b Compare January 2, 2025 16:48
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 2, 2025
@mateusoliveira43
Copy link
Contributor Author

@camilamacedo86 updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR that requires an org member to verify it 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.

3 participants