Skip to content

WIP: [IGNORE] test add v1beta2 API version#6209

Open
willie-yao wants to merge 11 commits into
kubernetes-sigs:mainfrom
willie-yao:v1beta2-controllers
Open

WIP: [IGNORE] test add v1beta2 API version#6209
willie-yao wants to merge 11 commits into
kubernetes-sigs:mainfrom
willie-yao:v1beta2-controllers

Conversation

@willie-yao
Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind api-change

What this PR does / why we need it:

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 #

Special notes for your reviewer:

TODOs:

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

Release note:

Add v1beta2 API

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Apr 7, 2026
@k8s-ci-robot
Copy link
Copy Markdown
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 jont828 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 requested a review from jackfrancis April 7, 2026 07:12
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 7, 2026
@k8s-ci-robot k8s-ci-robot requested a review from jsturtevant April 7, 2026 07:12
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 7, 2026
@willie-yao willie-yao force-pushed the v1beta2-controllers branch 3 times, most recently from 61b422f to 5c0e317 Compare April 7, 2026 16:54
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 4.02720% with 1835 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.99%. Comparing base (55fe6f4) to head (e744d85).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
api/v1alpha1/zz_generated.conversion.go 0.00% 648 Missing ⚠️
api/v1beta1/conversion.go 0.00% 279 Missing ⚠️
api/v1alpha1/conversion.go 0.00% 68 Missing ⚠️
azure/mock_azure/azure_mock.go 0.00% 60 Missing ⚠️
azure/scope/cluster.go 18.75% 51 Missing and 1 partial ⚠️
api/v1beta2/tags.go 0.00% 40 Missing ⚠️
azure/scope/machine.go 2.43% 40 Missing ⚠️
azure/scope/machinepoolmachine.go 11.90% 37 Missing ⚠️
api/v1beta2/types.go 0.00% 36 Missing ⚠️
azure/scope/managedcontrolplane.go 2.94% 33 Missing ⚠️
... and 72 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6209      +/-   ##
==========================================
- Coverage   43.85%   35.99%   -7.86%     
==========================================
  Files         289      345      +56     
  Lines       25341    30909    +5568     
==========================================
+ Hits        11113    11127      +14     
- Misses      13450    18998    +5548     
- Partials      778      784       +6     

☔ 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.

@willie-yao willie-yao force-pushed the v1beta2-controllers branch 3 times, most recently from c4ee9d4 to 5cce3bc Compare April 8, 2026 23:20
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 9, 2026
@willie-yao willie-yao force-pushed the v1beta2-controllers branch 2 times, most recently from 42abc3c to d46f07c Compare April 10, 2026 16:58
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 10, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 10, 2026
@willie-yao willie-yao force-pushed the v1beta2-controllers branch from d46f07c to 6a51259 Compare April 10, 2026 18:41
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 10, 2026
@willie-yao willie-yao force-pushed the v1beta2-controllers branch from 6a51259 to 9b6f0d2 Compare April 10, 2026 20:21
@willie-yao
Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@willie-yao
Copy link
Copy Markdown
Contributor Author

/retest

@willie-yao
Copy link
Copy Markdown
Contributor Author

/test ls

@willie-yao
Copy link
Copy Markdown
Contributor Author

/test pull-cluster-api-provider-azure-conformance-custom-builds
/test pull-cluster-api-provider-azure-conformance-dual-stack-with-ci-artifacts
/test pull-cluster-api-provider-azure-conformance-ipv6-with-ci-artifacts
/test pull-cluster-api-provider-azure-conformance-with-ci-artifacts

@willie-yao
Copy link
Copy Markdown
Contributor Author

/retest

Create api/v1beta2/ and exp/api/v1beta2/ packages with all CAPZ
type definitions updated for the CAPI v1beta2 contract.

Key changes from v1beta1 types:
- status.ready (bool) → status.initialization.provisioned (*bool)
  One-time signal that must never revert to false once set.
- status.conditions (clusterv1beta1.Conditions) → status.conditions ([]metav1.Condition)
  Standard Kubernetes condition type at status.conditions (Stage 2).
- status.failureDomains (map) → status.failureDomains ([]FailureDomain slice)
- status.failureReason/failureMessage → status.deprecated.v1beta1.*
- AzureManagedControlPlane uses Available condition (not Ready) per CP contract.
- ControlPlaneEndpoint uses omitzero to prevent empty struct validation failures.
- spec.providerID changed from *string to string on AzureMachine.

This commit is purely additive — no existing code is modified.

Signed-off-by: William Yao <william2000yao@gmail.com>
Add conversion-gen output and ConvertTo/ConvertFrom methods for all
spoke types. Generated by conversion-gen v0.35.0 with --extra-peer-dirs
for cross-package CAPI types.

Types with conversion:
- api/v1beta1: 17 types (core + managed + templates + ASO)
- api/v1alpha1: 6 ASO managed types
- exp/api/v1beta1: AzureMachinePool, AzureMachinePoolMachine

This commit contains only generated code and thin wrappers.
Manual conversion for status fields that changed shape between versions:
- Ready (bool) ↔ Initialization.Provisioned (*bool)
- Initialized (bool) ↔ Initialization.ControlPlaneInitialized (*bool)
- FailureDomains map ↔ slice
- FailureReason/FailureMessage ↔ Deprecated.V1Beta1
- Conditions: v1beta1 → Deprecated.V1Beta1.Conditions

Critical roundtrip fix: CAPI's condition converters are intentional
no-ops producing zero-valued entries ({type:"",status:""}). Fix:
1. out.Conditions = nil after every autoConvert (both directions)
2. hasNonEmptyConditions() filters zero-valued artifacts

Signed-off-by: William Yao <william2000yao@gmail.com>
Configure all 19 CRDs for dual-version serving with v1beta2 as storage:
- +kubebuilder:storageversion on v1beta2, removed from v1beta1
- cluster.x-k8s.io/v1beta2: v1beta2 contract label on all CRDs
- Conversion webhook patches enabled for all multi-version CRDs
- CA injection patches for 9 types that were previously missing
- contract: v1beta2 in metadata.yaml and e2e test config

Signed-off-by: William Yao <william2000yao@gmail.com>
Mechanical change: update all import paths from api/v1beta1 to
api/v1beta2 (aliased as infrav1) across ~228 files.

Import alias rules updated in .golangci.yml:
- infrav1 → api/v1beta2, infrav1beta1 → api/v1beta1
- infrav1exp → exp/api/v1beta2, infrav1expbeta1 → exp/api/v1beta1

Signed-off-by: William Yao <william2000yao@gmail.com>
Update all 6 scope PatchObject methods for the v1beta2 contract:

1. V1beta2 conditions (Stage 2):
   - conditions.SetSummaryCondition() for Ready/Available summary
   - AzureCluster/Machine/Pool: Ready condition
   - AzureManagedControlPlane: Available condition (per CP contract)

2. V1beta1 dual-write for backward compatibility:
   - setV1Beta1ConditionsFromV1Beta2() converts v1beta2 conditions to
     clusterv1.Conditions and stores in Deprecated.V1Beta1.Conditions
   - patch.WithOwnedV1Beta1Conditions declares ownership
   - v1beta1 clients see conditions via v1beta2→v1beta1 conversion
   - Skips write when conditions are unchanged to avoid unnecessary
     resourceVersion bumps on stable objects

3. Condition ownership fixes:
   - Remove AgentPoolsReadyCondition from ManagedControlPlane summary:
     it was never set on ManagedControlPlane (only on ManagedMachinePool).
     The old v1beta1 SetSummary silently skipped it, but v1beta2
     SetSummaryCondition correctly reports missing conditions as Unknown.
   - Add AgentPoolsReadyCondition to ManagedMachinePool owned conditions:
     it IS set on this object by the agentpools service but was missing
     from WithOwnedConditions, meaning the patch helper would not include
     it in server-side apply patches.

This is simpler than CAPD's pattern of individual MarkTrue/MarkFalse
at every code path — we convert all conditions in one shot at
PatchObject time.

Signed-off-by: William Yao <william2000yao@gmail.com>
- Add WithStatusSubresource to fake client builders (required for
  CAPI patch helper's Status().Patch() calls)
- Update TestConditions to expect Ready summary condition
- Fix type references from v1beta1 to v1beta2 in test code
…bhooks

Move AzureMachinePool and AzureMachinePoolMachine webhook registration
to internal/webhooks using v1beta2 types. This aligns them with all
other CAPZ webhooks and changes webhook paths from v1beta1 to v1beta2.

With matchPolicy: Equivalent, the API server converts v1beta1 requests
to v1beta2 before sending to the webhook, so v1beta1 clients work
transparently.
Fuzz-based roundtrip tests for all v1beta1↔v1beta2 conversions using
CAPI's utilconversion.FuzzTestFunc. Verify data survives spoke→hub→spoke
and hub→spoke→hub without corruption.

Custom fuzzers handle intentionally lossy fields:
- status.conditions: cleared on hub (no-op CAPI converters)
- FailureDomains: sorted after roundtrip (map→slice→map reorders)
- Initialization/Deprecated: derived from spoke fields

19 roundtrip tests: 17 api/v1beta1 + 2 exp/api/v1beta1.

Signed-off-by: William Yao <william2000yao@gmail.com>
Run make generate to update all generated files:
- GoMock files in azure/services/*/mock_*/
- CRD base manifests
- Webhook manifests (all paths now v1beta2)
- RBAC manifests

Signed-off-by: William Yao <william2000yao@gmail.com>
1. ASO isOwnedBy: Compare Group+Kind+Name only, ignoring API version.
   After v1beta1→v1beta2 upgrade, ASO resources retain v1beta1 owner refs
   but controller resolves v1beta2, causing IsManaged to return false and
   falling back to slow per-resource deletion instead of whole RG delete.

2. BYO node pool test: CAPI MachinePool controller (v1.13.0-rc.0) only
   sets conditions in deprecated.v1beta1 path, not v1beta2 conditions.
   Use deprecatedv1beta1conditions.IsTrue(ReadyV1Beta1Condition) to read
   from the correct path.
@willie-yao willie-yao force-pushed the v1beta2-controllers branch from 97bf4b7 to 3a17370 Compare April 15, 2026 00:35
@willie-yao
Copy link
Copy Markdown
Contributor Author

/retest-required

@willie-yao
Copy link
Copy Markdown
Contributor Author

/test pull-cluster-api-provider-azure-conformance-custom-builds
/test pull-cluster-api-provider-azure-conformance-dual-stack-with-ci-artifacts
/test pull-cluster-api-provider-azure-conformance-ipv6-with-ci-artifacts
/test pull-cluster-api-provider-azure-conformance-with-ci-artifacts

@willie-yao
Copy link
Copy Markdown
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 16, 2026
@willie-yao willie-yao force-pushed the v1beta2-controllers branch 2 times, most recently from fe78b53 to e744d85 Compare April 16, 2026 16:56
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 16, 2026
@willie-yao willie-yao force-pushed the v1beta2-controllers branch from e744d85 to 3a17370 Compare April 16, 2026 23:34
@willie-yao
Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@willie-yao
Copy link
Copy Markdown
Contributor Author

/retest

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@willie-yao: 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-conformance-with-ci-artifacts-dra e744d85 link false /test pull-cluster-api-provider-azure-conformance-with-ci-artifacts-dra
pull-cluster-api-provider-azure-conformance-with-ci-artifacts e744d85 link false /test pull-cluster-api-provider-azure-conformance-with-ci-artifacts
pull-cluster-api-provider-azure-apidiff 3a17370 link false /test pull-cluster-api-provider-azure-apidiff
pull-cluster-api-provider-azure-apiversion-upgrade 3a17370 link true /test pull-cluster-api-provider-azure-apiversion-upgrade

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 added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 1, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

PR needs rebase.

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.

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/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants