Skip to content

Conversation

psantus
Copy link
Contributor

@psantus psantus commented Oct 17, 2025

Description

See #44693 for bug description

Solution: we apply Mutex on Create and Delete operations. Slows down a bit but makes it reliable.

Relations

Closes #44693

References

https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateImageVersion.html

Output from Acceptance Testing

** With Mutex **

% TF_ACC=1 SAGEMAKER_IMAGE_VERSION_BASE_IMAGE="MASKED.PUT_EXISTING_ECR_URI_HERE" go test -v ./internal/service/sagemaker -run TestAccSageMakerImageVersion_concurrentCreation -timeout 30m
2025/10/17 15:11:09 Creating Terraform AWS Provider (SDKv2-style)...
2025/10/17 15:11:09 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccSageMakerImageVersion_concurrentCreation
=== PAUSE TestAccSageMakerImageVersion_concurrentCreation
=== CONT  TestAccSageMakerImageVersion_concurrentCreation
--- PASS: TestAccSageMakerImageVersion_concurrentCreation (441.94s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/sagemaker  446.801s

...

** Without Mutex **

% TF_ACC=1 SAGEMAKER_IMAGE_VERSION_BASE_IMAGE="MASKED.PUT_EXISTING_ECR_URI_HERE" go test -v ./internal/service/sagemaker -run TestAccSageMakerImageVersion_concurrentCreation -timeout 30m
2025/10/17 15:03:11 Creating Terraform AWS Provider (SDKv2-style)...
2025/10/17 15:03:11 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccSageMakerImageVersion_concurrentCreation
=== PAUSE TestAccSageMakerImageVersion_concurrentCreation
=== CONT  TestAccSageMakerImageVersion_concurrentCreation
    image_version_test.go:488: Step 1/1 error: Error running apply: exit status 1
        
        Error: creating SageMaker AI Image Version tf-acc-test-1054052909525976931: operation error SageMaker: CreateImageVersion, https response error StatusCode: 400, RequestID: 0f4e652d-d0c2-407e-94fc-72b1ebeccdd7, ResourceInUse: Resource was modified concurrently
        
          with aws_sagemaker_image_version.test4,
          on terraform_plugin_test.tf line 56, in resource "aws_sagemaker_image_version" "test4":
          56: resource "aws_sagemaker_image_version" "test4" {
        
        
        Error: creating SageMaker AI Image Version tf-acc-test-1054052909525976931: operation error SageMaker: CreateImageVersion, https response error StatusCode: 400, RequestID: 83aac55f-307d-4a13-ae52-799d1b053236, ResourceInUse: Resource was modified concurrently
        
          with aws_sagemaker_image_version.test26,
          on terraform_plugin_test.tf line 166, in resource "aws_sagemaker_image_version" "test26":
         166: resource "aws_sagemaker_image_version" "test26" {
        
        
        Error: creating SageMaker AI Image Version tf-acc-test-1054052909525976931: operation error SageMaker: CreateImageVersion, https response error StatusCode: 400, RequestID: 0d07b9d6-86d3-4877-a931-9cf141f968e5, ResourceInUse: Resource was modified concurrently
        
          with aws_sagemaker_image_version.test69,
          on terraform_plugin_test.tf line 381, in resource "aws_sagemaker_image_version" "test69":
         381: resource "aws_sagemaker_image_version" "test69" {
        
--- FAIL: TestAccSageMakerImageVersion_concurrentCreation (334.01s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/sagemaker  339.090s
FAIL

...

Copy link
Contributor

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. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/sagemaker Issues and PRs that pertain to the sagemaker service. size/M Managed by automation to categorize the size of a PR. labels Oct 17, 2025
@psantus psantus marked this pull request as ready for review October 17, 2025 13:42
@psantus psantus requested a review from a team as a code owner October 17, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-triage Waiting for first response or review from a maintainer. service/sagemaker Issues and PRs that pertain to the sagemaker service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws_sagemaker_image_version: ResourceInUse when multiple image versions are created / deleted for the same image (image_name)

1 participant