Skip to content

feat(sdk): Add per-service SDK tag fallback for model fetching#690

Open
sapphirew wants to merge 1 commit into
aws-controllers-k8s:mainfrom
sapphirew:feat/per-service-sdk-tags
Open

feat(sdk): Add per-service SDK tag fallback for model fetching#690
sapphirew wants to merge 1 commit into
aws-controllers-k8s:mainfrom
sapphirew:feat/per-service-sdk-tags

Conversation

@sapphirew
Copy link
Copy Markdown
Contributor

Issue #, if available:
aws-controllers-k8s/community#2859
Description of changes:

When a new AWS service is released, its model JSON is published under a per-service tag (e.g. service/s3files/v1.0.0) before the next core SDK tag is cut. This adds automatic fallback to per-service tags when the core tag returns HTTP 404.

Changes:

  • Extend EnsureModel with per-service URL fallback and separate cache
  • Add --aws-service-sdk-version CLI flag to ack-generate
  • Add version resolution priority chain (flag > metadata > empty)
  • Record aws_service_sdk_version in ack-generate-metadata.yaml
  • Add AWS_SERVICE_SDK_VERSION passthrough in build-controller.sh
  • Add unit tests for fallback, cache separation, URL construction, metadata round-trip, and EnsureSemverPrefix idempotence

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

@ack-prow ack-prow Bot requested review from jlbutler and knottnt April 16, 2026 19:02
@ack-prow
Copy link
Copy Markdown

ack-prow Bot commented Apr 16, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sapphirew
Once this PR has been reviewed and has the lgtm label, please assign jlbutler for approval by writing /assign @jlbutler in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@sapphirew
Copy link
Copy Markdown
Contributor Author

/retest

Copy link
Copy Markdown
Contributor

@knottnt knottnt left a comment

Choose a reason for hiding this comment

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

Thanks @sapphirew. Left some comments. Mostly questions about how we want to use the new flag.

Comment thread pkg/sdk/fetch.go
Comment thread pkg/sdk/fetch.go Outdated

// Core tag returned non-200 (likely 404)
if coreStatus == http.StatusNotFound && serviceSDKVersion != "" {
// Fallback to per-service tag
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: If the per-service-tag is able to represent a newer version of the api model file should it take precedence?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. The per-service API models are always more up to date until the core sdk catches up in a few weeks. It should take precedence when set

Comment thread pkg/sdk/fetch.go
//
// The returned string is the base path to use with NewHelper — it mirrors the
// SDK repo directory structure so that ModelAndDocsPath works unchanged.
func EnsureModel(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

p: having the logic for checking both the core and per-service versions is making this function quite a bit more complex. Wondering if it would be possible to make the decision on whether or not to use the core vs per-service version outside of this function and base the parameters we pass into this function on that decision.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we can always use per-service version when set. If core sdk version is set at the same time, return an error or warn

rootCmd.PersistentFlags().StringVar(
&optAWSSDKGoVersion, "aws-sdk-go-version", "", "Version of github.com/aws/aws-sdk-go-v2 used to generate apis and controllers files",
)
rootCmd.PersistentFlags().StringVar(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: Should this flag be mutually exclusive with aws-sdk-go-version? What are the scenarios where we'd want both to be set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. If core sdk version is set at the same time, we can return an error

When a new AWS service is released, its model JSON is published under a
per-service tag (e.g. service/s3files/v1.0.0) before the next core SDK
tag is cut. This adds automatic fallback to per-service tags when the
core tag returns HTTP 404.

Changes:
- Extend EnsureModel with per-service URL fallback and separate cache
- Add --aws-service-sdk-version CLI flag to ack-generate
- Add version resolution priority chain (flag > metadata > empty)
- Record aws_service_sdk_version in ack-generate-metadata.yaml
- Add AWS_SERVICE_SDK_VERSION passthrough in build-controller.sh
- Add unit tests for fallback, cache separation, URL construction,
  metadata round-trip, and EnsureSemverPrefix idempotence
@sapphirew sapphirew force-pushed the feat/per-service-sdk-tags branch from 74e60d6 to 2f10e7b Compare April 17, 2026 17:22
@ack-prow
Copy link
Copy Markdown

ack-prow Bot commented Apr 17, 2026

@sapphirew: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
dynamodb-controller-test 2f10e7b link true /test dynamodb-controller-test

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@knottnt knottnt self-requested a review April 17, 2026 22:41
Copy link
Copy Markdown
Contributor

@knottnt knottnt left a comment

Choose a reason for hiding this comment

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

Thanks @sapphirew! Left a few more comments.


// TestGenerationMetadata_BackwardCompatibility verifies that YAML without the
// aws_service_sdk_version field deserializes without error and the field
// defaults to empty string (Requirement 4.3).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: (Requirement 4.3). doesn't refer to anything.

Suggested change
// defaults to empty string (Requirement 4.3).
// defaults to empty string.

LastModification: lastModificationInfo{
Reason: UpdateReasonAPIGeneration,
},
AWSSDKGoVersion: "v1.41.5",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be good to also test that AWSSDKGoVersion is emitted as expected.

Comment thread pkg/sdk/fetch.go
totalStart time.Time,
) (string, error) {
normalizedSvcVer := EnsureSemverPrefix(serviceSDKVersion)
basePath := filepath.Join(cacheDir, "models", "service", modelName, normalizedSvcVer)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doing some testing modelName doesn't appear to work as-is for all controllers. For example the route53-controller uses route-53 as the model name, but the service package directory uses route53. Using svcAlias here instead may be a better general fit. Going forward we may also need to add a new generator.yaml sdk_names:pkg_name config similar to the sdk_names:model_name config that's causing route53's issue.

https://github.com/aws-controllers-k8s/route53-controller/blob/6b66359fac93b613ef69b68ac6e185137b9247f6/generator.yaml#L23

optGenVersion,
filepath.Join(optOutputPath, "apis"),
ackmetadata.UpdateReasonAPIGeneration,
optAWSSDKGoVersion,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Testing this PR against the s3-controller I see that after calling make build-controller SERVICE=s3 AWS_SERVICE_SDK_VERSION=v1.99.1 the ack-generate-metadata.yaml file looks like the below and includes both aws_sdk_go_version and aws_service_sdk_version. Should only one of these fields be emitted?

ack_generate_info:
  build_date: "2026-03-31T19:59:08Z"
  build_hash: a9e2ceaadfc00a742e2ea2b6d6c68348f03e52a5
  build_date: "2026-04-17T23:51:02Z"
  build_hash: 2f10e7b367cd01230a7916e4956c61f97be8cf13
  go_version: go1.26.1
  version: v0.58.0-3-ga9e2cea
api_directory_checksum: 379f9aa07359a58fabb591e795271b44a678b20c
  version: v0.58.0-5-g2f10e7b
api_directory_checksum: 29a8845f7c3bf83c6d20107a582b35d7a912d93a
api_version: v1alpha1
aws_sdk_go_version: v1.41.5
aws_service_sdk_version: v1.99.1
generator_config_info:
  file_checksum: 035386df2e486fac01a2dbedf247c36bbaeec7f3
  original_file_name: generator.yaml

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.

2 participants