Skip to content

Move webhooks out of exp/api/v1beta1#6280

Merged
k8s-ci-robot merged 1 commit into
kubernetes-sigs:mainfrom
mboersma:move-exp-webhooks
May 6, 2026
Merged

Move webhooks out of exp/api/v1beta1#6280
k8s-ci-robot merged 1 commit into
kubernetes-sigs:mainfrom
mboersma:move-exp-webhooks

Conversation

@mboersma
Copy link
Copy Markdown
Contributor

@mboersma mboersma commented May 6, 2026

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Mirrors #6141 for the exp/api/v1beta1 tree. Webhook code (validation + defaulting) and the supporting default-helpers move out of the API types package into purpose-built internal packages, leaving exp/api/v1beta1 to hold types and conversions only.

  • New internal/exp/api/v1beta1/ holds the Set* defaulters as free functions taking *infrav1exp.AzureMachinePool (was receiver methods on the type).
  • New internal/exp/webhooks/ holds the AzureMachinePoolWebhook and AzureMachinePoolMachineWebhook types plus the per-validator helpers.
  • ValidateAzureMachinePool(old, amp, client) is exported so the existing external test in exp/api/v1beta1/azuremachinepool_test.go (package v1beta1_test) can keep covering the validators directly.
  • main.go registers the webhooks from the new package.
  • The Makefile adds paths=./internal/exp/webhooks/... to the generate-manifests controller-gen invocation. config/webhook/manifests.yaml is byte-identical before and after — the same kubebuilder markers in their new home produce the same admission config.
  • exp/controllers/azuremachinepool_reconciler.go now calls apiinternalexp.SetNetworkInterfacesDefaults(s.scope.AzureMachinePool) instead of the receiver method.
  • Deletes the original exp/api/v1beta1/azuremachinepool_default.go, azuremachinepool_default_test.go, azuremachinepool_webhook.go, azuremachinepool_webhook_test.go, azuremachinepoolmachine_webhook.go. Git detected these as renames.

//nolint:staticcheck annotations on accesses to deprecated RoleAssignmentName, SubnetName, and AcceleratedNetworking mirror what #6141 added in internal/api/v1beta1/azuremachine_default.go — they're necessary because reading those fields from outside their defining package now triggers SA1019.

Which issue(s) this PR fixes:
Fixes #6167

Special notes for your reviewer:

The diff looks large but the bulk is mechanical: methods on *AzureMachinePool become free functions, and tests update their call-sites accordingly. The only behavioral change is the new package layout — all admission webhook semantics are unchanged (verified by the byte-identical config/webhook/manifests.yaml).

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
  • cherry-pick candidate

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label May 6, 2026
@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 6, 2026
@k8s-ci-robot k8s-ci-robot requested review from marosset and nojnhuh May 6, 2026 14:22
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 6, 2026
@mboersma mboersma force-pushed the move-exp-webhooks branch from fa24cd5 to 0e3eea6 Compare May 6, 2026 14:26
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 6, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 69.56522% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.84%. Comparing base (bd0f01b) to head (0e3eea6).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
...ternal/exp/api/v1beta1/azuremachinepool_default.go 70.83% 7 Missing ⚠️
internal/exp/webhooks/azuremachinepool_webhook.go 81.08% 6 Missing and 1 partial ⚠️
...al/exp/webhooks/azuremachinepoolmachine_webhook.go 0.00% 5 Missing ⚠️
main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6280      +/-   ##
==========================================
- Coverage   43.95%   43.84%   -0.11%     
==========================================
  Files         289      289              
  Lines       25351    25346       -5     
==========================================
- Hits        11143    11114      -29     
- Misses      13435    13458      +23     
- Partials      773      774       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mboersma mboersma requested review from jackfrancis and willie-yao May 6, 2026 15:23
Copy link
Copy Markdown
Contributor

@willie-yao willie-yao left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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

LGTM label has been added.

DetailsGit tree hash: 317aa06247659a98142013b4a7184bbf6fc72f09

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: willie-yao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 6, 2026
@willie-yao
Copy link
Copy Markdown
Contributor

/retest

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@mboersma: 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-cluster-api-provider-azure-e2e 0e3eea6 link unknown /test pull-cluster-api-provider-azure-e2e
pull-cluster-api-provider-azure-e2e-workload-upgrade 0e3eea6 link unknown /test pull-cluster-api-provider-azure-e2e-workload-upgrade
pull-cluster-api-provider-azure-apidiff 0e3eea6 link false /test pull-cluster-api-provider-azure-apidiff

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.

Details

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.

@k8s-ci-robot k8s-ci-robot merged commit dd13f2c into kubernetes-sigs:main May 6, 2026
20 of 23 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone May 6, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in CAPZ Planning May 6, 2026
@mboersma mboersma deleted the move-exp-webhooks branch May 7, 2026 01:32
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Remove webhooks from exp/api

3 participants