WIP: [IGNORE] test add v1beta2 API version#6209
WIP: [IGNORE] test add v1beta2 API version#6209willie-yao wants to merge 7 commits intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
61b422f to
5c0e317
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6209 +/- ##
==========================================
- Coverage 43.85% 36.23% -7.62%
==========================================
Files 289 344 +55
Lines 25341 30697 +5356
==========================================
+ Hits 11113 11124 +11
- Misses 13450 18791 +5341
- Partials 778 782 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c4ee9d4 to
5cce3bc
Compare
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, placed at status.conditions (Stage 2). - status.failureDomains (map[string]FailureDomainSpec) → status.failureDomains ([]FailureDomain) Slice with Name field instead of map key. - status.failureReason/failureMessage → status.deprecated.v1beta1.failureReason/failureMessage - New status.deprecated.v1beta1 struct for backward compat fields. - 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. All shared types (NetworkSpec, SubnetSpec, etc.) are duplicated per version, consistent with CAPZ's v1alpha3/v1alpha4 precedent. This commit is purely additive — no existing code is modified.
Implement ConvertTo/ConvertFrom on all v1beta1 spoke types for
conversion to/from the v1beta2 hub. Also add v1alpha1→v1beta2
conversion for the ASO managed types.
Manual conversion functions handle fields that changed shape:
- Ready (bool) ↔ Initialization.Provisioned (*bool)
- Initialized (bool) ↔ Initialization.ControlPlaneInitialized (*bool)
- FailureDomains map ↔ slice (with Name field)
- FailureReason/FailureMessage ↔ Deprecated.V1Beta1 location
- Conditions: v1beta1 conditions go to Deprecated.V1Beta1.Conditions
Critical fix: CAPI's Convert_v1beta1_Condition_To_v1_Condition and
Convert_v1_Condition_To_v1beta1_Condition are intentional no-ops that
produce zero-valued conditions ({type:"",status:""}). To prevent these
from corrupting data during roundtrips (v1beta2→v1beta1→v1beta2 caused
by CAPI controllers doing SSA at v1beta1), we:
1. Clear out.Conditions = nil after every autoConvert call in BOTH
directions (13 functions total)
2. Use hasNonEmptyConditions() helper instead of len(in.Conditions)>0
to filter out zero-valued artifacts before creating Deprecated structs
Types with conversion (10 v1beta1 + 6 v1alpha1):
- AzureCluster, AzureMachine, AzureClusterTemplate, AzureMachineTemplate
- AzureClusterIdentity, AzureMachinePool, AzureMachinePoolMachine
- AzureManagedCluster, AzureManagedControlPlane, AzureManagedMachinePool
- AzureManagedClusterTemplate, AzureManagedControlPlaneTemplate,
AzureManagedMachinePoolTemplate (new, were missing)
- AzureASOManagedCluster/ControlPlane/MachinePool (new, were missing)
Generated conversion: conversion-gen v0.34.0 with --extra-peer-dirs
for cross-package CAPI types. 23 manual Convert_ functions override
the auto-generated ones for fields that changed shape.
Configure all CRDs for dual-version serving with v1beta2 as storage: - +kubebuilder:storageversion on v1beta2, removed from v1beta1 - cluster.x-k8s.io/v1beta2: v1beta2 label on all CRDs - cluster.x-k8s.io/v1beta1: v1beta1 label retained for compat - Conversion webhook patches enabled for ALL 19 multi-version CRDs (previously only 7 had them; managed types, templates, and ASO types were missing because they only had one version before) - CA injection patches created for 9 types that were missing them - contract: v1beta2 in metadata.yaml and e2e test config The conversion webhook patches point all CRDs to /convert on the capz-webhook-service. controller-runtime automatically registers this handler when SetupWebhookWithManager is called on a hub type.
Mechanical change: update all import paths from api/v1beta1 to api/v1beta2 (aliased as infrav1) and exp/api/v1beta1 to exp/api/v1beta2 (aliased as infrav1exp). The old versions are now aliased as infrav1beta1/infrav1expbeta1 where still needed. This touches ~228 files across: - azure/services/* (all Azure service implementations) - azure/converters/* (type converters) - controllers/ (all reconcilers) - exp/controllers/ (experimental reconcilers) - internal/webhooks/ (all webhook implementations) - internal/api/v1beta1/ (defaulting logic) - pkg/, util/ (shared utilities) - main.go (scheme registration, webhook setup) - test/e2e/ (e2e test helpers) Import alias rules updated in .golangci.yml: - infrav1 → api/v1beta2 - infrav1beta1 → api/v1beta1 - infrav1exp → exp/api/v1beta2 - infrav1expbeta1 → exp/api/v1beta1 No behavioral changes — just import paths and type references.
Update all 6 scope PatchObject methods for the v1beta2 contract:
1. Conditions migration (Stage 2):
- Use conditions.SetSummaryCondition() for v1beta2 Ready/Available
summary conditions at status.conditions ([]metav1.Condition)
- AzureCluster/Machine/Pool: Ready condition
- AzureManagedControlPlane: Available condition (per CP contract)
2. V1beta1 dual-write for backward compatibility:
- New setV1Beta1ConditionsFromV1Beta2() helper converts v1beta2
[]metav1.Condition to clusterv1.Conditions and stores them in
Deprecated.V1Beta1.Conditions via SetV1Beta1Conditions()
- This ensures v1beta1 clients see conditions when the
v1beta2→v1beta1 conversion webhook runs
- patch.WithOwnedV1Beta1Conditions declares ownership to prevent
merge conflicts when the Ready condition changes
This approach is simpler than CAPD's pattern of individual
MarkTrue/MarkFalse at every code path (~50-100 sites). Instead,
we convert all v1beta2 conditions in one shot at PatchObject time,
which automatically covers all conditions without risk of missing one.
- Add WithStatusSubresource to fake client builders in 5 tests. Required because the CAPI patch helper now uses Status().Patch() for condition handling, which needs the status subresource enabled on the fake client. - Update TestConditions expectations to include the new Ready summary condition alongside individual conditions (VMRunning etc.) - Fix type references from v1beta1 to v1beta2 in test code.
Run make generate to update all generated files: - GoMock files in azure/services/*/mock_*/ - azure/mock_azure/azure_mock.go - api/v1beta1 and exp/api/v1beta1 type markers (hub → spoke) - api/v1alpha1 groupversion registration updates - Makefile conversion-gen target updates - exp/api/v1beta1 webhook and default function signature updates No hand-written changes — purely generated output and marker updates.
497fa14 to
42abc3c
Compare
|
@willie-yao: The following tests failed, say
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. DetailsInstructions 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. |
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:
Release note: