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

Convert all singleton lists in the MR APIs to embedded objects #508

Merged
merged 16 commits into from
May 16, 2024

Conversation

ulucinar
Copy link
Collaborator

@ulucinar ulucinar commented Apr 20, 2024

Description of your changes

Depends on: crossplane/upjet#387, crossplane/upjet#400

Terraform configuration blocks, even if they have a MaxItems constraint of 1, are (almost) always generated as lists. We
now generate the lists with a MaxItems constraint of 1 as embedded objects in our MR APIs.

This also helps when updating or patching via SSA the (previously list) objects. The merging strategy implemented by SSA requires configuration for associative lists and converting the singleton lists into embedded objects removes the configuration need.

The provider generates the converted embedded objects in the new v1beta2 versions of the CRD APIs and registers upjet's identity converter and the singleton list converters to be invoked, in chain, by the CRD API conversion webhooks. This implies that the v1beta1 versions stay intact, and old clients not aware of the new APIs should continue functioning as before (backwards-compatibility). Any clients willing to use the embedded objects-based APIs should be updated to use the v1beta2 versions of the CRD APIs.

If a resource contains no singleton lists, then the v1beta2 version is not generated for it.

We had to configure field name overrides for HTTP{S}HealthCheck.compute and Version.dialogflowcx so that the correspnding type names for the spec.forProvider, spec.initParameter and state.atProvider fields are not duplicated with the introduction of v1beta2 packages.

We have also removed the SSA merge strategy configurations from the v1beta2 versions of Cluster.container & NodePool.container resources because the related fields are no longer lists and have been converted to embedded objects in their v1beta2 versions.

I have:

  • Read and followed Crossplane'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.
  • New versions for the converted CRD APIs
  • Replace config.Resource.References[*].Type with config.Resource.References[*].TerraformName
  • Adjust the manually authored example manifests: With Add example manifests for v1beta2 version #528
  • API Conversion functions (invoked by the Conversion webhooks) to convert between the new & old API versions

How has this code been tested

A successful uptest run for the 'NodePool.container` resource with the API converters is registered here.
Another run with GKE back plans is here.

Also via the following uptest runs:

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar ulucinar force-pushed the embed-singleton branch 2 times, most recently from 0ec1128 to 2242799 Compare April 21, 2024 00:24
@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

2 similar comments
@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar ulucinar force-pushed the embed-singleton branch 2 times, most recently from 535e79b to 0d7096c Compare April 21, 2024 20:52
@ulucinar
Copy link
Collaborator Author

/test-examples="examples/gke/v1beta2/backupbackupplan.yaml"

1 similar comment
@ulucinar
Copy link
Collaborator Author

/test-examples="examples/gke/v1beta2/backupbackupplan.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/gke/v1beta2/backupbackupplan.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/gke/v1beta2/backupbackupplan.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar
Copy link
Collaborator Author

ulucinar commented Apr 22, 2024

Hi @JonathanO,
This PR converts the singleton lists in the provider API to embedded objects together with the converter functions invoked by the conversion webhooks to convert between the (old) v1beta1 APIs (where the APIs are singleton lists) and the new v1beta2 APIs (where the APIs are embedded objects).

We've done some preliminary tests using the {Cluster,NodePool}.eks, ServiceAccount.cloudplatform and BackupBackupPlan.gke resources using uptest. Also built resource providers using the v1.1.0-db914f4f8174cbf845f9df9895b9826ed26d2e6c tag.

It would be great if you could provide us some feedback using these providers:

  • Family config provider: xpkg.upbound.io/upbound/provider-family-gcp:v1.1.0-db914f4f8174cbf845f9df9895b9826ed26d2e6c
  • Monolith: xpkg.upbound.io/upbound/provider-gcp:v1.1.0-db914f4f8174cbf845f9df9895b9826ed26d2e6c

As discussed above, the resource providers (except for the new containerattached provider) have also the same tag v1.1.0-db914f4f8174cbf845f9df9895b9826ed26d2e6c, i.e., xpkg.upbound.io/upbound/provider-gcp-container:v1.1.0-db914f4f8174cbf845f9df9895b9826ed26d2e6c.

This is a relatively large & involved change (both the code generation pipelines and the provider runtime are affected and we also attempt to hide the breaking API changes from the v1beta1 clients). I would really appreciate if you could give these providers a try in your test environment if you can spare some time.

Not all v1beta2 example manifests have been updated to reflect the API changes. However, if you'd like to check here are some manifests updated to facilitate testing:

  • examples/gke/v1beta2/backupbackupplan.yaml
  • examples/container/v1beta2/{cluster,nodepool}.yaml
  • examples/gke/v1beta2/backupbackupplan.yaml

P.S. There's also a counterpart of this PR in crossplane-contrib/provider-upjet-azuread.

@turkenf
Copy link
Collaborator

turkenf commented Apr 22, 2024

/test-examples="examples/bigquery/v1beta1/routine.yaml"

@turkenf
Copy link
Collaborator

turkenf commented Apr 22, 2024

/test-examples="examples/compute/v1beta1/nodegroup.yaml"

@turkenf
Copy link
Collaborator

turkenf commented Apr 22, 2024

/test-examples="examples/dns/v1beta1/policy.yaml"

@turkenf
Copy link
Collaborator

turkenf commented Apr 22, 2024

/test-examples="examples/sql/v1beta1/user.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/compute/v1beta2/firewall.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/compute/v1beta2/instance.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/compute/v1beta2/router.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/pubsub/v1beta2/litetopic.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/cloudrun/v1beta2/v2service.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/logging/v1beta2/metric.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/monitoring/v1beta2/service.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/notebooks/v1beta2/environment.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/notebooks/v1beta2/instance.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/secretmanager/v1beta2/secret.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/sql/v1beta2/user.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/dns/v1beta2/policy.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/container/v1beta2/cluster.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/storage/v1beta2/bucket.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/spanner/v1beta2/database.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/redis/v1beta2/instance.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/compute/v1beta2/securitypolicy.yaml"

@sergenyalcin
Copy link
Collaborator

/test-examples="examples/compute/v1beta2/urlmap.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/compute/v1beta2/image.yaml"

Copy link
Collaborator

@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 for your amazing efforts on this PR, LGTM! I think after removing the replace in go.mod and pointing to uptest latest, we will be ready to merge.

Comment on lines +75 to +76
UPTEST_LOCAL_VERSION = v0.12.0-9.gac371c9
UPTEST_LOCAL_CHANNEL = main
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: We may consider using after releaseing the uptest with the import fix. I am not proposing to do this in this PR. I want to only note this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, agreed. Let's revisit this once upbound/build#255 is merged. Thanks for the note.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that we need to fix the example generation pipeline to produce examples via using the new generated APIs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this is another item we need to take care of. Let's merge this PR, and address the missing example manifests with a separate PR.

…e.PreviousVersions

for the prevention of the type name conflicts in the generated multi-versioned CRDs.

- config.Resource.OverrideFieldNames is being deprecated in favor of
  config.Resource.PreviousVersions.
- Bump upjet to commit 92d1af84d242.

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
@ulucinar
Copy link
Collaborator Author

/test-examples="examples/container/v1beta2/nodepool.yaml"

@ulucinar
Copy link
Collaborator Author

/test-examples="examples/compute/v1beta2/image.yaml"

@ulucinar
Copy link
Collaborator Author

We've decided to merge this PR without the example manifests and @sergenyalcin is planning to open a follow-up PR to introduce the missing v1beta2 example manifests.

@ulucinar ulucinar merged commit e623a2b into crossplane-contrib:main May 16, 2024
10 of 11 checks passed
@ulucinar ulucinar deleted the embed-singleton branch May 16, 2024 12:57
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