feat(sdk): Add per-service SDK tag fallback for model fetching#690
feat(sdk): Add per-service SDK tag fallback for model fetching#690sapphirew wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sapphirew The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/retest |
knottnt
left a comment
There was a problem hiding this comment.
Thanks @sapphirew. Left some comments. Mostly questions about how we want to use the new flag.
|
|
||
| // Core tag returned non-200 (likely 404) | ||
| if coreStatus == http.StatusNotFound && serviceSDKVersion != "" { | ||
| // Fallback to per-service tag |
There was a problem hiding this comment.
Q: If the per-service-tag is able to represent a newer version of the api model file should it take precedence?
There was a problem hiding this comment.
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
| // | ||
| // 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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Q: Should this flag be mutually exclusive with aws-sdk-go-version? What are the scenarios where we'd want both to be set?
There was a problem hiding this comment.
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
74e60d6 to
2f10e7b
Compare
|
@sapphirew: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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
left a comment
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
nit: (Requirement 4.3). doesn't refer to anything.
| // defaults to empty string (Requirement 4.3). | |
| // defaults to empty string. |
| LastModification: lastModificationInfo{ | ||
| Reason: UpdateReasonAPIGeneration, | ||
| }, | ||
| AWSSDKGoVersion: "v1.41.5", |
There was a problem hiding this comment.
It would be good to also test that AWSSDKGoVersion is emitted as expected.
| totalStart time.Time, | ||
| ) (string, error) { | ||
| normalizedSvcVer := EnsureSemverPrefix(serviceSDKVersion) | ||
| basePath := filepath.Join(cacheDir, "models", "service", modelName, normalizedSvcVer) |
There was a problem hiding this comment.
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.
| optGenVersion, | ||
| filepath.Join(optOutputPath, "apis"), | ||
| ackmetadata.UpdateReasonAPIGeneration, | ||
| optAWSSDKGoVersion, |
There was a problem hiding this comment.
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
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:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.