-
Notifications
You must be signed in to change notification settings - Fork 447
Migrated AzureASOManaged API to v1beta1 #5660
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
Migrated AzureASOManaged API to v1beta1 #5660
Conversation
ab6673f
to
bc4de75
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5660 +/- ##
==========================================
- Coverage 53.20% 52.83% -0.37%
==========================================
Files 272 278 +6
Lines 29583 29610 +27
==========================================
- Hits 15740 15645 -95
- Misses 13023 13148 +125
+ Partials 820 817 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bc4de75
to
ccb7856
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good so far!
I forgot about the None
spec.conversion.strategy for CRDs which means we don't have to implement any conversion webhooks as long as there's no delta between v1alpha1 and v1beta1. We should make sure that if we do end up adding something to v1beta1 before we remove v1alpha1, we can change that and add conversion webhooks without causing any compatibility issues, and if CI will somehow flag that None
is no longer viable when some change is introduced.
The other thing we should address is how to update the templates. I think the aks-aso
flavor template can be updated to v1beta1 right away. For tests it would be best to cover both versions, but I'd probably prefer v1beta1 if we can only pick one.
type azureASOManagedClusterWebhook struct { | ||
} | ||
|
||
// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedcluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedclusters,versions=v1alpha1,name=validation.azureasomanagedcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update these references here to the new API version too (and also for the other new _webhook.go
files):
// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedcluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedclusters,versions=v1alpha1,name=validation.azureasomanagedcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 | |
// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azureasomanagedcluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedclusters,versions=v1beta1,name=validation.azureasomanagedcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should be able to remove the v1alpha1 webhooks entirely.
I see CAPI only implements webhooks for v1beta2 Clusters. Conversion must automatically take care of the rest. I at least see the same validation applied to both v1alpha1 and v1beta1 of AzureASOManagedCluster with only the one webhook defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping this here for myself to make sure no unexpected changes sneak in:
for alpha in api/v1alpha1/azureasomanaged*; do beta=${alpha/v1alpha1/v1beta1}; [ -f $beta ] && git diff --no-index $alpha $beta; done
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:storageversion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't covered in e2e atm, but we should at least manually verify that upgrading from a previous version of CAPZ that used v1alpha1 as the storage version doesn't break existing workload clusters when the CRD is updated to the new storage version.
We should definitely follow up soon after this though with automated tests if we absolutely have to cut the release with the rest of these changes before then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finished manually verify that upgrading from a previous version of CAPZ that used v1alpha1 as the storage version doesn't break existing workload clusters when the CRD is updated to the new storage version.
Did this by
- switching to main branch that uses v1alpha1 and spinning up my management and workload aks-aso cluster
- switching to dev branch that uses v1beta1, rerunning make generate, and rerunning make tilt-up (this applied the updates correctly)
- used cli to verify storage versions and logs
- scaled the machine pools and worked
- added tags in the ManagedCluster in the AzureASOManagedControlPlane and it shows up in Azure Portal
- checked CAPZ and CAPI logs and only errors are the deprecated v1alpha1 warnings we added
One other chunk here I forgot is updating the controllers to operate against the new API version. That should be as simple as updating all of the imports that look like this: infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" to: infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" The only place I think we still need that is in main.go. Pro tip: I think vscode's go plugin knows how to rename imports, so the easiest way to go about this is:
|
Can you elaborate on this @nojnhuh ? Are you saying to keep infrav1alpha in main.go? |
``Also editing resource_reconciler.go because ResourceStatus type uses v1alpha1 which is used in resourceStatusObject interface in controllers like in here
|
83bd0b6
to
1cbf62f
Compare
Yes that's what I meant. After playing around with it though, it looks like we don't need that if we update to use v1beta1 everywhere within the CAPZ binary. Let's try removing all imports to the v1alpha1 package (including removing it in main.go) and see how that fares in CI. |
Not to steal any of the fun here, but I noticed this extractable smaller chunk of work we need as part of making a new API version available but doesn't require any of the changes here to work on its own: #5662. |
Name string `json:"name"` | ||
} | ||
|
||
// +kubebuilder:object:root=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mark each of the v1alpha1 types as deprecated per https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#version-deprecation.
I see kubebuilder makes that easy with a marker like this:
//+kubebuilder:deprecatedversion:warning="infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedCluster is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should be used instead."
Then that warning gets blasted whenever that API version is used to prompt people to update:
% kubectl get azureasomanagedcluster.v1alpha1.infrastructure.cluster.x-k8s.io
Warning: infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedCluster is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 should be used instead.
NAME AGE
aks-aso-6548 45s
f856b58
to
f9bf705
Compare
afbf238
to
3f26fb8
Compare
3f26fb8
to
cc6e31a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
LGTM label has been added. Git tree hash: 4b29a0d5ee97971ff02db865317cf31d57a17a31
|
I see the feature gate is already enabled by default, but let's also graduate the feature gate to GA to approach parity with the existing AKS things:
|
ASOAPI: permanent reserved term for ffs, as APIs mature/removed the ff capabilities will change |
1c69599
to
e941db9
Compare
One last nit: I see a couple lingering references to v1alpha1 in the docs that we might as well clean up:
|
e941db9
to
5aafd56
Compare
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
Great work on this!
LGTM label has been added. Git tree hash: eefdb09b5f2a9aeab6702f86c16d3c235546236b
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nojnhuh 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 |
/test pull-cluster-api-provider-azure-e2e |
/retest-required |
1 similar comment
/retest-required |
/test pull-cluster-api-provider-azure-e2e |
#5686 again /test pull-cluster-api-provider-azure-e2e |
@alimaazamat: The following test 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. 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. |
/test pull-cluster-api-provider-azure-e2e |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Based on this roadmap: https://capz.sigs.k8s.io/roadmap
We want to move AzureASOManaged API from v1alpha1 to v1beta1.
Edited aks-aso flavor template to use new v1beta1.
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 #5659
Special notes for your reviewer:
TODOs:
Release note: