Skip to content
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

Fix empty TypeMeta while running API conversions #424

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

ulucinar
Copy link
Collaborator

@ulucinar ulucinar commented Jul 25, 2024

Description of your changes

When running the API conversion functions for multi-version CRDs, there are cases, as discussed in kubernetes/client-go#541, where the v1.TypeMeta information has been dropped. This breaks non-wildcard conversion function filtering performed by the conversion webhook.

I have:

  • Read and followed Upjet's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Tested against crossplane-contrib/provider-upjet-aws resource Instance.rds with conversions between the versions v1beta1, v1beta2, and v1beta3. Here are the steps (Note that testing the fix requires building an image, because conversion functions won't work in a provider running outside of the cluster — unless you jump through the hoops):

  1. Install a provider image, built before the fix (this PR).
  2. Apply the v1beta1 MR manifest below.
  3. Run kubectl get instance.v1beta2.rds.aws.upbound.io/test-upjet-pr-424-db.
  4. Observe that name field in v1beta1 was lost when converted to storage version v1beta2 (field renaming conversion).
  5. Repeat for other versions.
  6. Delete the resource.
  7. Build and load a provider image with the fix (this PR).
  8. Apply the same manifest.
  9. Run kubectl get instance.v1beta2.rds.aws.upbound.io/test-upjet-pr-424-db.
  10. Observe that name field in v1beta1 was converted successfully to dbName in v1beta2.
  11. Repeat for other versions.

Resource manifest

Note that we supply an invalid providerConfigRef to prevent provisioning the external resource, because we don't need the resource to test conversion functions.

apiVersion: rds.aws.upbound.io/v1beta1
kind: Instance
metadata:
  annotations:
    meta.upbound.io/example-id: rds/v1beta1/instance
    uptest.upbound.io/timeout: "3600"
  labels:
    testing.upbound.io/example-name: example-dbinstance
  name: test-upjet-pr-424-db
spec:
  forProvider:
    name: example
    region: us-west-1
    allocatedStorage: 20
    autoMinorVersionUpgrade: true
    backupRetentionPeriod: 14
    instanceClass: db.t3.micro
    engine: postgres
    engineVersion: "16.1"
    username: adminuser
    autoGeneratePassword: true
    passwordSecretRef:
      key: password
      name: example-dbinstance
      namespace: upbound-system
    backupWindow: "09:46-10:16"
    maintenanceWindow: "Mon:00:00-Mon:03:00"
    publiclyAccessible: false
    skipFinalSnapshot: true
    storageEncrypted: true
    storageType: gp2
  providerConfigRef:
    name: nonexistingproviderconfig
  writeConnectionSecretToRef:
    name: example-dbinstance-out
    namespace: default

@ulucinar ulucinar marked this pull request as draft July 25, 2024 11:04
@ulucinar ulucinar marked this pull request as ready for review July 25, 2024 11:04
@ulucinar
Copy link
Collaborator Author

Hi @turkenf, @mergenci,
Could you please take over this? Please ping me if help is needed.

@mergenci mergenci self-assigned this Jul 30, 2024
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
@mergenci mergenci force-pushed the fix-conversion-typemeta branch from e489efa to a08ecd7 Compare November 4, 2024 21:08
@mergenci
Copy link
Member

Thanks for the fix @ulucinar. It's working successfully. I've completed the PR description. Could you please review @sergenyalcin and @erhancagirici?

Copy link
Member

@sergenyalcin sergenyalcin left a comment

Choose a reason for hiding this comment

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

Thanks @ulucinar LGTM!

@mergenci mergenci merged commit ba35c31 into crossplane:main Nov 15, 2024
6 checks passed
@ulucinar ulucinar deleted the fix-conversion-typemeta branch November 19, 2024 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants