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

Migrate Certificate Manager DNSAuthorization API #2561

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

anhdle-sso
Copy link
Collaborator

@anhdle-sso anhdle-sso commented Aug 22, 2024

Change description

Fixes #

Tests you have done

  • Run make ready-pr to ensure this PR is ready for review.
  • Perform necessary E2E testing for changed resources.

@anhdle-sso
Copy link
Collaborator Author

/assign @justinsb

@Hamzawy63
Copy link
Contributor

Hamzawy63 commented Aug 29, 2024

@anhdle-sso

Hi Anh,

I work Certificate Manager team and happened to see this pull request by accident. Just curious, could you provide me more context about this pull request? Is it part of the recent efforts to improve the config connector (https://github.com/GoogleCloudPlatform/k8s-config-connector?tab=readme-ov-file#-coming-soon-a-new-way-to-write-the-controller-) ?

Also, is the defined schema for this resource based on the the latest version that the config connector had? or will it be up-to-date with the API ? Are we no longer based on the Terraform Provider Google beta version?

I'm asking because the latest version we had in KCC didn't include the recently-added Enum field Type (https://cloud.google.com/certificate-manager/docs/reference/certificate-manager/rest/v1/projects.locations.dnsAuthorizations#type) and I wonder whether it will be supported after the migration or we will still need service team intervention to support it?

@yuwenma
Copy link
Collaborator

yuwenma commented Aug 29, 2024

@Hamzawy63
Yes, it is part of the recent "Direct resource" effort.
Right, we will support the new fields as long as

  1. they are added before this Direct resource migration.
  2. they show up in the google go client library that your team owns.

@anhdle-sso anhdle-sso force-pushed the migrate_api_dns_auth branch 2 times, most recently from 7a80250 to 2af3156 Compare September 3, 2024 20:20
Comment on lines 58 to 59
excluded_resources=("computeforwardingrule")
excluded_resources=("computeforwardingrule" "certificatemanagerdnsauthorization")

Copy link
Collaborator

Choose a reason for hiding this comment

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

So for a beta resource, we suggest not excluding the CRD generation using excluded_resources, because it gives the PR reviewing no clue on whether the outcome is correct or not (also it would be very error prone for the developers).

Instead, you can add the cnrm.cloud.google.com/dcl2crd: "true” in the type go tag. (example), and comment out those new fields that do not exist in the TF-based resources according to the outcome from dev/task/generate-crds. Guide here

Copy link
Collaborator

@yuwenma yuwenma left a comment

Choose a reason for hiding this comment

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

Looks good! One comment about avoid using the excluded_resources flag so that we can compare whether this PR is backward compatible since the resource is already in Beta.

Copy link
Collaborator

@maqiuyujoyce maqiuyujoyce left a comment

Choose a reason for hiding this comment

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

LGTM with a few non-blocking nits.

@anhdle-sso anhdle-sso closed this Sep 4, 2024
@anhdle-sso anhdle-sso reopened this Sep 4, 2024
@anhdle-sso
Copy link
Collaborator Author

Looks good! One comment about avoid using the excluded_resources flag so that we can compare whether this PR is backward compatible since the resource is already in Beta.

The current CRD also has v1alpha1 information. if I do not exclude this resource; the v1alpha1 part will be deleted which might cause issue for customer who is using v1alpha1.

@yuwenma
Copy link
Collaborator

yuwenma commented Sep 4, 2024

Looks good! One comment about avoid using the excluded_resources flag so that we can compare whether this PR is backward compatible since the resource is already in Beta.

The current CRD also has v1alpha1 information. if I do not exclude this resource; the v1alpha1 part will be deleted which might cause issue for customer who is using v1alpha1.

you can include the alpha resource in the direct types. here's the related section in the guide.

@anhdle-sso anhdle-sso force-pushed the migrate_api_dns_auth branch 2 times, most recently from 685bb42 to 14aa100 Compare September 4, 2024 23:31
@anhdle-sso
Copy link
Collaborator Author

Looks good! One comment about avoid using the excluded_resources flag so that we can compare whether this PR is backward compatible since the resource is already in Beta.

done. added alpha resource and regen crds

@@ -308,9 +341,3 @@ spec:
storage: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you try to:

  1. Install the old CRD and create a CertificateManagerDNSAuthorization resource.
  2. Upgrade to the new CRD.
  3. Verify whether the upgrade works and whether the existing CertificateManagerDNSAuthorization successfully reconciled based on the new schema?

The reason I asked here is that we've never switched the storage version from v1alpha1 to v1beta1 so we probably want to be extra careful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tested by following these steps:

  1. Checkout to master
  2. Apply the existing crd kubectl apply -f config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_certificatemanagerdnsauthorizations.certificatemanager.cnrm.cloud.google.com.yaml; make deploy-controller && kubectl delete pods --namespace cnrm-system --all
  3. Apply sample DNS Authorization kubectl apply -f config/samples/resources/certificatemanagerdnsauthorization/certificatamanager_v1beta1_certificatemanagerdnsauthorization.yaml
  4. Check into my branch with new change and run step 2 again with an extra log line to confirm that the new controller is deployed.
  5. Wait a bit and confirm that the resource is still good.
  6. Make a change in the resource and apply again to force reconciliation.
  7. The resource is updated and ready.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome, thank you!

@maqiuyujoyce
Copy link
Collaborator

/lgtm though you'll probably want to figure out why the validation still fails.

Copy link
Collaborator

@yuwenma yuwenma left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Awesome! Thanks!

Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yuwenma

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@yuwenma yuwenma added this to the 1.123 milestone Sep 9, 2024
// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded"
// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'"
// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'"
// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=alpha";"cnrm.cloud.google.com/tf2crd=true"
Copy link
Collaborator

@yuwenma yuwenma Sep 9, 2024

Choose a reason for hiding this comment

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

The validation test seems to be wrong. It cannot deal with multi-versions correctly. You can remove the cnrm.cloud.google.com/stability-level here or update the validation check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants