Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_container_group - set storage_account_key in the update operation #26640

Merged
merged 9 commits into from
Aug 8, 2024

Conversation

neil-yechenwei
Copy link
Contributor

@neil-yechenwei neil-yechenwei commented Jul 15, 2024

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

API needs storage account key while updating the container group with storage account. Otherwise, the update API call would fail.

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Below failed test cases are also failed with same error on Teamcity Daily Run. So they are not related with this PR.
image

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_container_group - set storage_account_key in the update operation

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #26631

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

@neil-yechenwei neil-yechenwei marked this pull request as draft July 15, 2024 12:50
@neil-yechenwei neil-yechenwei marked this pull request as ready for review July 15, 2024 13:42
Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Thanks @neil-yechenwei.

Unfortunately all the tests for container group have been failing since the 2nd of July with the same error

=== CONT  TestAccContainerGroup_AssignedIdentityUpdate
    testcase.go:121: Step 1/3 error: Error running apply: exit status 1
        Error: creating Container Group (Subscription: "*******"
        Resource Group Name: "acctestRG-240730232202481222"
        Container Group Name: "acctestcontainergroup-240730232202481222"): performing ContainerGroupsCreateOrUpdate: unexpected status 409 (409 Conflict) with error: RegistryErrorResponse: An error response is received from the docker registry 'index.docker.io'. Please retry later.

So I'm unable to run the tests for this. Would you be able to reach out to the service team about this?

@neil-yechenwei
Copy link
Contributor Author

@stephybun , sure. I will check with service team about the failure.

@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Aug 2, 2024

@stephybun , service team said that this is a known issue due to docker imposing stricter rate limits on docker public registry : DockerHub Rate limit with Azure Container Instance and AKS | by alaa barqawi | Jul, 2024 | Medium. When a rate limit is hit, ACI is unable to pull images from docker, and deployment fails.
To avoid these errors, we are requesting customers to use images from MCR or use ACR for their private images. So I updated this PR accordingly. Below is the test result I just now triggered. All related test cases are passed.

image
image

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the tests @neil-yechenwei. I left one more suggestions in-line, once that's resolved this should be good to go.

Comment on lines 860 to 882
// As API doesn't return the value of StorageAccountKey, so it has to get the value from tf config and set it to request payload. Otherwise, the Update API call would fail
addedEmptyDirs := map[string]bool{}
_, initContainerVolumes, err := expandContainerGroupInitContainers(d, addedEmptyDirs)
if err != nil {
return err
}
_, _, containerVolumes, err := expandContainerGroupContainers(d, addedEmptyDirs)
if err != nil {
return err
}
var containerGroupVolumes []containerinstance.Volume
if initContainerVolumes != nil {
containerGroupVolumes = initContainerVolumes
}
if containerGroupVolumes != nil {
containerGroupVolumes = append(containerGroupVolumes, containerVolumes...)
}
model.Properties.Volumes = pointer.To(containerGroupVolumes)

// As Update API doesn't support to update identity, so it has to use CreateOrUpdate API to update identity
if err := client.ContainerGroupsCreateOrUpdateThenPoll(ctx, *id, model); err != nil {
return fmt.Errorf("updating %s: %+v", *id, err)
}
Copy link
Member

Choose a reason for hiding this comment

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

If only the tags are updated then we would be making an unnecessary update call. I think this whole block should be moved into

if d.HasChange("identity") {
...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Aug 8, 2024

@stephybun , thanks for the comments. I updated PR. Please take another look. Below is the latest test result I just now triggered and all test cases passed.
image
image

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Thanks @neil-yechenwei LGTM ⭐

@stephybun stephybun added the bug label Aug 8, 2024
@stephybun stephybun merged commit 81742d5 into hashicorp:main Aug 8, 2024
31 checks passed
@github-actions github-actions bot added this to the v3.115.0 milestone Aug 8, 2024
stephybun added a commit that referenced this pull request Aug 8, 2024
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modifying tag of container group with storage volume results in InvalidStorageAccountKey error
2 participants