-
Notifications
You must be signed in to change notification settings - Fork 637
🐛 fix: ensure correct APIVersion in AWSClusterControllerIdentity conversion #5738
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
base: main
Are you sure you want to change the base?
🐛 fix: ensure correct APIVersion in AWSClusterControllerIdentity conversion #5738
Conversation
…sion The conversion webhook for AWSClusterControllerIdentity was failing with: - expected infrastructure.cluster.x-k8s.io/v1beta2, received infrastructure.cluster.x-k8s.io/v1beta1 - Error from server: conversion webhook returned invalid object: invalid groupVersion Root cause: The auto-generated conversion function (Convert_v1beta1_AWSClusterControllerIdentity_To_v1beta2_AWSClusterControllerIdentity) copies TypeMeta directly from the source object, which includes the APIVersion field. This results in the converted v1beta2 object retaining the v1beta1 APIVersion, causing the conversion webhook to reject it as invalid. Fix: Explicitly set the APIVersion to the target version (v1beta2) after calling the auto-generated conversion function in both ConvertTo methods for AWSClusterControllerIdentity and AWSClusterControllerIdentityList. This ensures the converted object has the correct APIVersion that matches the target API version expected by Kubernetes. This fix ensures that when Kubernetes requests conversion from v1beta1 to v1beta2, the webhook returns objects with the correct APIVersion, allowing the conversion to succeed.
|
[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.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
0a62f61 to
9e21452
Compare
Add comprehensive e2e tests to verify the conversion webhook fix for AWSClusterControllerIdentity. The tests verify: 1. Basic conversion test: - Creates AWSClusterControllerIdentity in v1beta1 format using kubectl - Verifies the resource can be retrieved and has correct v1beta2 APIVersion - Tests both kubectl get and Go client retrieval - Verifies list operations work correctly 2. Provider upgrade simulation test: - Simulates creating resource with old provider (v1beta1) - Simulates provider upgrade scenario - Verifies conversion webhook correctly converts v1beta1 to v1beta2 - Verifies resource spec is preserved during conversion - Tests both kubectl and Go client access patterns These tests ensure that the conversion webhook fix properly handles the APIVersion field during conversion, preventing the error: 'expected infrastructure.cluster.x-k8s.io/v1beta2, received infrastructure.cluster.x-k8s.io/v1beta1' Signed-off-by: dntosas <[email protected]>
9e21452 to
8b13926
Compare
|
@dntosas: 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. |
/kind bug
The conversion webhook for AWSClusterControllerIdentity was failing with:
Root cause:
The auto-generated conversion function (Convert_v1beta1_AWSClusterControllerIdentity_To_v1beta2_AWSClusterControllerIdentity) copies TypeMeta directly from the source object, which includes the APIVersion field. This results in the converted v1beta2 object retaining the v1beta1 APIVersion, causing the conversion webhook to reject it as invalid.
Fix:
Explicitly set the APIVersion to the target version (v1beta2) after calling the auto-generated conversion function in both ConvertTo methods for AWSClusterControllerIdentity and AWSClusterControllerIdentityList. This ensures the converted object has the correct APIVersion that matches the target API version expected by Kubernetes.
This fix ensures that when Kubernetes requests conversion from v1beta1 to v1beta2, the webhook returns objects with the correct APIVersion, allowing the conversion to succeed.
What type of PR is this?
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:
Checklist:
Release note: