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 validating and mutating webhook for supervisor mode #2651

Merged
merged 1 commit into from
May 22, 2024

Conversation

zhanggbj
Copy link
Contributor

@zhanggbj zhanggbj commented Jan 23, 2024

What this PR does / why we need it:

Add validating and mutating webhook for supervisor mode:

- Refactor supervisor config folder and generate webhook config and manifest.
- Enable update validating for vm-operator VSphereMachine to block in-place update of following fields.
	- ImageName
	- ClassName
	- StorageClass
	- MinHardwareVersion

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

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 23, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 23, 2024
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 15 lines in your changes are missing coverage. Please review.

Project coverage is 64.07%. Comparing base (b89c791) to head (4ec4228).
Report is 2 commits behind head on main.

❗ Current head 4ec4228 differs from pull request most recent head e910494. Consider uploading reports for the commit e910494 to get more accurate results

Files Patch % Lines
internal/webhooks/vmoperator/vspheremachine.go 72.09% 10 Missing and 2 partials ⚠️
internal/test/helpers/envtest.go 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2651      +/-   ##
==========================================
- Coverage   65.48%   64.07%   -1.42%     
==========================================
  Files         161      161              
  Lines        7525     9391    +1866     
==========================================
+ Hits         4928     6017    +1089     
- Misses       2134     2914     +780     
+ Partials      463      460       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhanggbj zhanggbj changed the title [WIP] ✨ Add validating webhook for vm-operator VSphereMachine ✨ Add validating webhook for vm-operator VSphereMachine Jan 24, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 24, 2024
@zhanggbj
Copy link
Contributor Author

It's ready for a review. And I'll try to add some tests if possible to make codecov happy.

@chrischdi
Copy link
Member

It's ready for a review. And I'll try to add some tests if possible to make codecov happy.

Thanks, please ignore codecov, its not failing because of your PR, its the usual codecov flakyness when uploading the report 😭

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

All in all great code :-)

Some nits.

internal/webhooks/vmoperator/vspheremachine.go Outdated Show resolved Hide resolved
internal/webhooks/vmoperator/vspheremachine.go Outdated Show resolved Hide resolved
internal/webhooks/vmoperator/vspheremachine.go Outdated Show resolved Hide resolved
internal/webhooks/vmoperator/vspheremachine.go Outdated Show resolved Hide resolved
internal/webhooks/vmoperator/vspheremachine.go Outdated Show resolved Hide resolved
@zhanggbj
Copy link
Contributor Author

zhanggbj commented Jan 25, 2024

All comments addressed, it's ready for another review :-)

@zhanggbj
Copy link
Contributor Author

/test pull-cluster-api-provider-vsphere-test-main

internal/webhooks/vmoperator/vspheremachine.go Outdated Show resolved Hide resolved
internal/webhooks/vmoperator/vspheremachine.go Outdated Show resolved Hide resolved
internal/webhooks/vmoperator/vspheremachine_test.go Outdated Show resolved Hide resolved
internal/webhooks/vmoperator/vspheremachine_test.go Outdated Show resolved Hide resolved
@sbueringer
Copy link
Member

sbueringer commented Jan 25, 2024

Once we have the manifests working. Let's please do one manual test with tilt/kind or something (with a real Kubernetes cluster not just unit tests) to verify the webhooks are really active. It's very easy to make a mistake somewhere (e.g. incorrect / missing webhook manifests, incorrect resource match in the webhook config, ...)

@zhanggbj
Copy link
Contributor Author

Once we have the manifests working. Let's please do one manual test with tilt/kind or something (with a real Kubernetes cluster not just unit tests) to verify the webhooks are really active. It's very easy to make a mistake somewhere (e.g. incorrect / missing webhook manifests, incorrect resource match in the webhook config, ...)

Make sense to me, will run tilt to verify it and update result later.

@zhanggbj zhanggbj force-pushed the vmop_vm_webhook branch 2 times, most recently from b512e4c to 3ac090a Compare January 31, 2024 06:54
@zhanggbj
Copy link
Contributor Author

zhanggbj commented Feb 4, 2024

/test pull-cluster-api-provider-vsphere-test-integration-main

@zhanggbj zhanggbj changed the title ✨ Add validating webhook for vm-operator VSphereMachine [WIP] ✨ Add validating webhook for vm-operator VSphereMachine Feb 4, 2024
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 4, 2024
@zhanggbj zhanggbj force-pushed the vmop_vm_webhook branch 4 times, most recently from 3456b2c to 4506f71 Compare February 6, 2024 09:43
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 10, 2024
@sbueringer
Copy link
Member

@zhanggbj: The following test 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-cluster-api-provider-vsphere-test-integration-main 4ec4228 link true /test pull-cluster-api-provider-vsphere-test-integration-main
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Interesting that Prow shows us a job run from February :) https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api-provider-vsphere/2651/pull-cluster-api-provider-vsphere-test-integration-main/1759866415801700352

(we deleted the job since then, so let's ignore)

@sbueringer
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 16, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 0cbe2e1a85f3451505df183f9a362f7067af0325

@sbueringer
Copy link
Member

/test pull-cluster-api-provider-vsphere-e2e-govmomi-main
/test pull-cluster-api-provider-vsphere-e2e-supervisor-main

@sbueringer
Copy link
Member

/test pull-cluster-api-provider-vsphere-e2e-govmomi-main

@chrischdi
Copy link
Member

This is nice :-)

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 16, 2024
@sbueringer
Copy link
Member

/hold

for some manual testing

@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 May 16, 2024
@sbueringer
Copy link
Member

The govmomi test now failed 2 times in a row. I'm starting to think we broke something

/test pull-cluster-api-provider-vsphere-e2e-govmomi-main

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented May 16, 2024

@zhanggbj: The following test 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-cluster-api-provider-vsphere-test-integration-main 4ec4228 link true /test pull-cluster-api-provider-vsphere-test-integration-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

@sbueringer
Copy link
Member

Okay 3 times in a row seems too often

@zhanggbj
Copy link
Contributor Author

Checked the test artifacts, the failed cluster is quick-start-3x2kmb and it's blocked at WaitForOneKubeadmControlPlaneMachineToExist, which seems blocked due to no ready node.
From the kubelet.log, the latest error is CNI not ready as below, I cannot think of any relationship with this PR change🧐

May 16 11:17:54.628315 quick-start-3x2kmb-7q8wn kubelet[1552]: E0516 11:17:54.628259    1552 kubelet.go:2900] "Container runtime network not ready" networkReady="NetworkReady=false reason:NetworkPluginNotReady message:Network plugin returns error: cni plugin not initialized"

@sbueringer
Copy link
Member

/test pull-cluster-api-provider-vsphere-e2e-govmomi-main

@sbueringer
Copy link
Member

Same, but the job is 100% green on main. Let's see if it fails again. We might have to figure out why exactly the job is failing

@chrischdi
Copy link
Member

chrischdi commented May 17, 2024

The one at pull-cluster-api-provider-vsphere-e2e-govmomi-main was in fact a flake. We also have that on release branches.

xref triage

@zhanggbj
Copy link
Contributor Author

Interesting... the flakes all failed at /home/prow/go/pkg/mod/sigs.k8s.io/cluster-api/[email protected]/framework/controlplane_helpers.go:153

The one at pull-cluster-api-provider-vsphere-e2e-govmomi-main was in fact a flake. We also have that on release branches.

xref triage

@sbueringer
Copy link
Member

Kk. Maybe just bad luck :)

@sbueringer
Copy link
Member

/test pull-cluster-api-provider-vsphere-e2e-govmomi-main

@sbueringer
Copy link
Member

sbueringer commented May 17, 2024

Let's run it 2-3 more times overall and if it looks better, then let's merge it (assuming the manual tests are also completed)

@sbueringer
Copy link
Member

sbueringer commented May 17, 2024

Okay looking better, great :)

/test pull-cluster-api-provider-vsphere-e2e-govmomi-main

@chrischdi
Copy link
Member

/test pull-cluster-api-provider-vsphere-e2e-govmomi-main

@sbueringer
Copy link
Member

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 22, 2024
@k8s-ci-robot k8s-ci-robot merged commit 4e8f26a into kubernetes-sigs:main May 22, 2024
18 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.11 milestone May 22, 2024
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement validating webhook for vm-operator VSphereMachine
4 participants