Skip to content

Conversation

ulucinar
Copy link
Contributor

@ulucinar ulucinar commented Jan 17, 2022

  • Fixes #1089
  • Adds config.ResourceConfig.APIVersion to be able to
    override the generated version for a CRD

Issue #, if available: #1089

Description of changes:
This PR proposes a new configuration field named APIVersion (JSON-serialized name api_version) in config.ResourceConfig that allows overriding versions of specific CRDs generated by the Crossplane codegen pipeline. If a specific version string is not configured for a CRD-type, the default version specified with the --version command-line argument is used for backwards-compatibility. An example configuration overriding the version for the CloudFront Distribution resource is as follows:

resources:
  "Distribution":
    api_versions:
    - name: "v1beta1"
      storage: true
ignore:
  resource_names:
    - FieldLevelEncryptionProfile
    - Invalidation
    - KeyGroup
    - OriginRequestPolicy
    - PublicKey
    - StreamingDistribution
    - RealtimeLogConfig
    - MonitoringSubscription
    - FieldLevelEncryptionConfig
  field_paths:
    - DistributionConfig.CallerReference
    - Origins.Quantity
    - OriginAccessIdentityConfig.CallerReference

This PR now introduces a backward-incompatible behavior change in the Crossplane pipeline:
Because the generator configuration is per API group (service) and because we may now have resources belonging to different API versions in a single group, this PR changes the default path of the generator-config.yaml file from:
apis/<API group>/<API version>/generator-config.yaml
to
apis/<API group>/generator-config.yaml

An example invocation ack-generate crossplane cloudfront --output <output path> --generator-config-path generator-config.yaml using the above configuration yields the following file structure:

tree
.
├── apis
│   └── cloudfront
│       ├── v1alpha1
│       │   ├── zz_cache_policy.go
│       │   ├── zz_cloud_front_origin_access_identity.go                                                                                [0/941]
│       │   ├── zz_doc.go
│       │   ├── zz_enums.go
│       │   ├── zz_function.go
│       │   ├── zz_groupversion_info.go
│       │   ├── zz_response_headers_policy.go
│       │   └── zz_types.go
│       └── v1beta1
│           ├── zz_distribution.go
│           ├── zz_doc.go
│           ├── zz_enums.go
│           ├── zz_groupversion_info.go
│           └── zz_types.go
├── generator-config.yaml
├── go.mod
├── go.sum
└── pkg
    └── controller
        └── cloudfront
            ├── cachepolicy
            │   ├── zz_controller.go
            │   └── zz_conversions.go
            ├── cloudfrontoriginaccessidentity
            │   ├── zz_controller.go
            │   └── zz_conversions.go
            ├── distribution
            │   ├── zz_controller.go
            │   └── zz_conversions.go
            ├── function
            │   ├── zz_controller.go
            │   └── zz_conversions.go
            └── responseheaderspolicy
                ├── zz_controller.go
                └── zz_conversions.go

12 directories, 26 files

Without the resources configuration block, all resources are under v1alpha1 version as expected:

tree .
.
├── apis                                                                                                                               [0/1036]
│   └── cloudfront
│       └── v1alpha1
│           ├── zz_cache_policy.go
│           ├── zz_cloud_front_origin_access_identity.go
│           ├── zz_distribution.go
│           ├── zz_doc.go
│           ├── zz_enums.go
│           ├── zz_function.go
│           ├── zz_groupversion_info.go
│           ├── zz_response_headers_policy.go
│           └── zz_types.go
├── generator-config.yaml
├── go.mod
├── go.sum
└── pkg
    └── controller
        └── cloudfront
            ├── cachepolicy
            │   ├── zz_controller.go
            │   └── zz_conversions.go
            ├── cloudfrontoriginaccessidentity
            │   ├── zz_controller.go
            │   └── zz_conversions.go
            ├── distribution
            │   ├── zz_controller.go
            │   └── zz_conversions.go
            ├── function
            │   ├── zz_controller.go
            │   └── zz_conversions.go
            └── responseheaderspolicy
                ├── zz_controller.go
                └── zz_conversions.go

11 directories, 22 files

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

- Fixes #1089
- Adds config.ResourceConfig.APIVersion to be able to
  override the generated version for a CRD

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

ack-bot commented Jan 17, 2022

Hi @ulucinar. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@ack-bot ack-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 17, 2022
@vijtrip2
Copy link
Contributor

/ok-to-test

@ack-bot ack-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 18, 2022
@vijtrip2
Copy link
Contributor

/approve

Looks good but I will let @jaypipes approve on new GeneratorConfig field name.
And I will also let @a-hilaly to approve as he is working on supporting multi-version CRs for ACK controllers.

@a-hilaly
Copy link
Member

Looks like this change is only impacting ackgenerate crossplane and doesn't touch any other components. I'm fine with merging this if it's solving crossplane issue and satisfies their versioning criterias. However ACK and crossplane CRD versioning philosophies will take different paths.
I pinged @ulucinar and @muvaf on slack to chat about this subject
/hold for now

@ack-bot ack-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 19, 2022
@ulucinar
Copy link
Contributor Author

ulucinar commented Jan 19, 2022

Hi @a-hilaly,
Thank you for taking a look at this PR. I saw some existing work around supporting multiple versions for the generated CRDs, and I think you are referring to that work. This implementation follows @muvaf's suggestion here. Let's get together as you suggested to discuss the path we would like to take. My understanding is that in the Crossplane pipeline, for the first phase, we (currently) need to be able to control the API version for the generated CRDs with per-resource configuration, and multiple versions per CRD is not currently in the scope of #1089. Let's discuss when @muvaf is back.

@a-hilaly
Copy link
Member

Thanks @ulucinar ! Meeting scheduled tomorrow with Upbound folks @ulucinar and @muvaf.
Unholding the PR
/unhold

@ack-bot ack-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 20, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Jan 20, 2022

@a-hilaly: The /retest command does not accept any targets.
The following commands are available to trigger jobs:

  • /test unit-test
  • /test s3-olm-test
  • /test dynamodb-controller-test
  • /test ecr-controller-test
  • /test s3-controller-test

Use /test all to run all jobs.

In response to this:

/retest all

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/test-infra repository.

@a-hilaly
Copy link
Member

/test all

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

LGTM! left one nit comment

)

metaVars := m.MetaVars()
detectedCRDVersions := make(map[string]struct{})
Copy link
Member

Choose a reason for hiding this comment

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

nit: s/struct{}/bool/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved. Thank you.

@a-hilaly
Copy link
Member

/test s3-controller-test

- Allow multiple CRD versions to be configured
  for the generated CRDs

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

@muvaf, as detailed in the description of this PR, we will need to move generator-config.yamls to unversioned API group roots. And for resources with API version configurations, we will generate CRDs at the storage API version.

ulucinar added a commit to ulucinar/provider-aws that referenced this pull request Jan 26, 2022
- Consume aws-controllers-k8s/code-generator#266
  that implements support for specifying API versions of the generated
  CRDs.
- Move generator-config.yaml files to unversioned API group parent
  folders, because an API Group may now contain multiple versions.

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
@a-hilaly
Copy link
Member

/test all

ulucinar added a commit to ulucinar/provider-aws that referenced this pull request Jan 28, 2022
- Consume aws-controllers-k8s/code-generator#266
  that implements support for specifying API versions of the generated
  CRDs.
- Move generator-config.yaml files to unversioned API group parent
  folders, because an API Group may now contain multiple versions.

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
ulucinar added a commit to ulucinar/provider-aws that referenced this pull request Jan 28, 2022
@a-hilaly
Copy link
Member

Spoken with @muvaf and @ulucinar about this PR. Will make changes in #122. Merging to unblock crossplane folks for now.
/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Jan 28, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, ulucinar, vijtrip2

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

@ack-bot ack-bot merged commit 3f6e80a into aws-controllers-k8s:main Jan 28, 2022
@ulucinar ulucinar deleted the fix-1089 branch January 28, 2022 14:57
@ulucinar
Copy link
Contributor Author

Thank you @a-hilaly, very much appreciated!

ulucinar added a commit to ulucinar/provider-aws that referenced this pull request Jan 28, 2022
- Consume aws-controllers-k8s/code-generator#266
  that implements support for specifying API versions of the generated
  CRDs.
- Move generator-config.yaml files to unversioned API group parent
  folders, because an API Group may now contain multiple versions.

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
ulucinar added a commit to ulucinar/provider-aws that referenced this pull request Jan 28, 2022
- Consume aws-controllers-k8s/code-generator#266
  that implements support for specifying API versions of the generated
  CRDs.
- Move generator-config.yaml files to unversioned API group parent
  folders, because an API Group may now contain multiple versions.

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
ezgidemirel pushed a commit to ezgidemirel/provider-aws that referenced this pull request Feb 2, 2022
- Consume aws-controllers-k8s/code-generator#266
  that implements support for specifying API versions of the generated
  CRDs.
- Move generator-config.yaml files to unversioned API group parent
  folders, because an API Group may now contain multiple versions.

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants