Skip to content

Conversation

@psantus
Copy link
Contributor

@psantus psantus commented Nov 6, 2025

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

No changes to security controls.

Description

Fixes race condition in aws_sagemaker_image_version when creating multiple versions concurrently. Previously, waitImageVersionCreated called DescribeImageVersion without specifying a version parameter, which returns the latest version according to AWS API documentation. This caused all concurrent image version creations to get assigned the same (latest) version number.

The fix extracts the version number from the CreateImageVersion response ARN and uses it in a new version-specific wait function waitImageVersionCreatedByVersion, ensuring each resource waits for its specific version to be created.

Also removes unused functions that are no longer needed after the fix.

Relations

Closes #44959

References

Output from Acceptance Testing

console
% SAGEMAKER_IMAGE_VERSION_BASE_IMAGE="763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-training:1.13.1-gpu-py39-cu117-ubuntu20.04-sagemaker" make testacc PKG=sagemaker TESTARGS='-run=TestAccSageMakerImageVersion_basic'

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 fix/create_image_version-get-version-from-call-return 🌿...
TF_ACC=1 go1.24.8 test ./internal/service/sagemaker/... -v -count 1 -parallel 20 -run=TestAccSageMakerImageVersion_basic -timeout 360m -vet=off
2025/11/06 11:16:55 Creating Terraform AWS Provider (SDKv2-style)...
2025/11/06 11:16:55 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccSageMakerImageVersion_basic
=== PAUSE TestAccSageMakerImageVersion_basic
=== CONT TestAccSageMakerImageVersion_basic
--- PASS: TestAccSageMakerImageVersion_basic (95.39s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/sagemaker 100.141s

…ondition

Use specific version number from CreateImageVersion response when waiting for creation to complete, preventing race condition where multiple concurrent image version creations would all get assigned the latest version number.
…dition fix

Remove waitImageVersionCreated, statusImageVersionByName, and findImageVersionByName functions that are no longer used after implementing version-specific waiting.
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/sagemaker Issues and PRs that pertain to the sagemaker service. size/S Managed by automation to categorize the size of a PR. labels Nov 6, 2025
Use correct caps in function name: extractVersionFromARN instead of extractVersionFromArn
@psantus psantus marked this pull request as ready for review November 6, 2025 11:19
@psantus psantus requested a review from a team as a code owner November 6, 2025 11:19
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

@github-actions github-actions bot added the size/M Managed by automation to categorize the size of a PR. label Nov 6, 2025
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Addresses a defect in current functionality. service/sagemaker Issues and PRs that pertain to the sagemaker service. size/M Managed by automation to categorize the size of a PR. size/S Managed by automation to categorize the size of a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition in aws_sagemaker_image_version when creating multiple versions concurrently

2 participants