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

Add error handling for ALREADY_EXISTS in IAM CreateServiceAccount call #9727

Merged

Conversation

benhxy
Copy link
Contributor

@benhxy benhxy commented Dec 29, 2023

Introduce an optional resource argument to Google Cloud IAM Service Account. If ignore_create_already_exists is set to true, resource creation would succeed if response error is 409 ALREADY_EXISTS.

Fixes hashicorp/terraform-provider-google#16185
Fixes hashicorp/terraform-provider-google#10193

Release Note Template for Downstream PRs (will be copied)

iam: introducde an optional resource argument to Google Cloud IAM Service Account. If `ignore_create_already_exists` is set to true, resource creation would succeed if response error is 409 ALREADY_EXISTS.

@modular-magician
Copy link
Collaborator

Hello! I am a robot. It looks like you are a: Community Contributor Googler Core Contributor. Tests will run automatically.

@rileykarson, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 2 files changed, 33 insertions(+), 1 deletion(-))
Terraform Beta: Diff ( 2 files changed, 33 insertions(+), 1 deletion(-))

@benhxy
Copy link
Contributor Author

benhxy commented Dec 29, 2023

To reviewer: an alternative argument name could be create_ignore_already_exists. Please advise if there are better names.

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 135
Passed tests 103
Skipped tests: 30
Affected tests: 2

Click here to see the affected service packages
  • resourcemanager

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccServiceAccount_basic|TestAccDataSourceGoogleServiceAccountIdToken_impersonation

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataSourceGoogleServiceAccountIdToken_impersonation[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccServiceAccount_basic[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 2 files changed, 65 insertions(+), 1 deletion(-))
Terraform Beta: Diff ( 2 files changed, 65 insertions(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 0
Passed tests 0
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • resourcemanager

$\textcolor{red}{\textsf{Errors occurred during REPLAYING mode. Please fix them to complete your PR}}$
View the build log

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 2 files changed, 75 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 2 files changed, 75 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 0
Passed tests 0
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • resourcemanager

$\textcolor{red}{\textsf{Errors occurred during REPLAYING mode. Please fix them to complete your PR}}$
View the build log

@benhxy benhxy force-pushed the benhxy/create-already-exists branch from 456cf0c to 321ccc2 Compare January 2, 2024 21:06
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 77 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 3 files changed, 77 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 0
Passed tests 0
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • resourcemanager

$\textcolor{red}{\textsf{Errors occurred during REPLAYING mode. Please fix them to complete your PR}}$
View the build log

@benhxy benhxy force-pushed the benhxy/create-already-exists branch from 321ccc2 to d53e888 Compare January 2, 2024 22:50
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 77 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 3 files changed, 77 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 0
Passed tests 0
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • resourcemanager

$\textcolor{red}{\textsf{Errors occurred during REPLAYING mode. Please fix them to complete your PR}}$
View the build log

@benhxy
Copy link
Contributor Author

benhxy commented Jan 2, 2024

Hmm I'm a bit stuck on the build error. When I clicked in the build log, it only has one line:

FAIL	github.com/hashicorp/terraform-provider-google-beta/google-beta/services/resourcemanager [build failed]

Locally, I followed https://googlecloudplatform.github.io/magic-modules/get-started/generate-providers/ to set up the environment.

Then with my change in magic-modules, I ran make provider VERSION=beta OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google-beta" PRODUCT=resourcemanager RESOURCE=google_service_account.

It showed a lot of /Users/bensea/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.4.6/lib/bundler/shared_helpers.rb:58:in getwd': Too many open files - getcwd (Errno::EMFILE)` but that probably didn't matter.

It also updated many other products even when I specified PRODUCT and RESOURCE filter.

But most importantly, it didn't update the files I edited in magic-modules:

terraform-provider-google-beta bensea$ git status | grep resourcemanager
	modified:   google-beta/services/resourcemanager/data_source_google_folders.go
	modified:   google-beta/services/resourcemanager/data_source_google_iam_testable_permissions_test.go
	modified:   google-beta/services/resourcemanager/data_source_google_organization.go
	modified:   google-beta/services/resourcemanager/data_source_google_organization_test.go
	modified:   google-beta/services/resourcemanager/data_source_google_project_organization_policy.go
	modified:   google-beta/services/resourcemanager/data_source_google_project_service.go
	modified:   google-beta/services/resourcemanager/data_source_google_project_service_test.go
	modified:   google-beta/services/resourcemanager/data_source_google_projects.go
	modified:   google-beta/services/resourcemanager/data_source_google_projects_test.go
	modified:   google-beta/services/resourcemanager/data_source_google_service_account.go
	modified:   google-beta/services/resourcemanager/data_source_google_service_account_access_token.go
	modified:   google-beta/services/resourcemanager/data_source_google_service_account_access_token_test.go
	modified:   google-beta/services/resourcemanager/data_source_google_service_account_id_token.go
	modified:   google-beta/services/resourcemanager/data_source_google_service_account_id_token_test.go
	modified:   google-beta/services/resourcemanager/data_source_google_service_account_jwt_test.go
	modified:   google-beta/services/resourcemanager/resource_google_project_migrate_test.go
	modified:   google-beta/services/resourcemanager/resource_google_service_account_key_test.go
	modified:   google-beta/services/resourcemanager/resource_google_service_account_sweeper.go

@rileykarson appreciate your help here.

@benhxy benhxy force-pushed the benhxy/create-already-exists branch from d53e888 to 312dd6d Compare January 3, 2024 16:57
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 76 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 3 files changed, 76 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 136
Passed tests 105
Skipped tests: 30
Affected tests: 1

Click here to see the affected service packages
  • resourcemanager

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccServiceAccount_createIgnoreAlreadyExists

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{The provider crashed while running the VCR tests in RECORDING mode}}$
$\textcolor{red}{\textsf{Please fix it to complete your PR}}$
View the build log

@benhxy benhxy force-pushed the benhxy/create-already-exists branch from 312dd6d to d803a80 Compare January 3, 2024 17:31
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 4 files changed, 78 insertions(+), 7 deletions(-))
Terraform Beta: Diff ( 3 files changed, 78 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 136
Passed tests 105
Skipped tests: 30
Affected tests: 1

Click here to see the affected service packages
  • resourcemanager

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccServiceAccount_createIgnoreAlreadyExists

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{The provider crashed while running the VCR tests in RECORDING mode}}$
$\textcolor{red}{\textsf{Please fix it to complete your PR}}$
View the build log

@benhxy benhxy force-pushed the benhxy/create-already-exists branch from d803a80 to 1fc10be Compare January 3, 2024 18:47
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 80 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 3 files changed, 80 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 136
Passed tests 105
Skipped tests: 30
Affected tests: 1

Click here to see the affected service packages
  • resourcemanager

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccServiceAccount_createIgnoreAlreadyExists

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccServiceAccount_createIgnoreAlreadyExists[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

@benhxy
Copy link
Contributor Author

benhxy commented Jan 3, 2024

Tests are fixed.

@rileykarson rileykarson merged commit 6126630 into GoogleCloudPlatform:main Jan 8, 2024
14 checks passed
bskaplan pushed a commit to bskaplan/magic-modules that referenced this pull request Jan 17, 2024
GoogleCloudPlatform#9727)

* Add error handling for ALREADY_EXISTS in IAM CreateServiceAccount call

* Use a separate unit test for create_ignore_already_exists
kylase pushed a commit to yuanchuankee/magic-modules that referenced this pull request Jan 21, 2024
GoogleCloudPlatform#9727)

* Add error handling for ALREADY_EXISTS in IAM CreateServiceAccount call

* Use a separate unit test for create_ignore_already_exists
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request May 2, 2024
GoogleCloudPlatform#9727)

* Add error handling for ALREADY_EXISTS in IAM CreateServiceAccount call

* Use a separate unit test for create_ignore_already_exists
pengq-google pushed a commit to pengq-google/magic-modules that referenced this pull request May 21, 2024
GoogleCloudPlatform#9727)

* Add error handling for ALREADY_EXISTS in IAM CreateServiceAccount call

* Use a separate unit test for create_ignore_already_exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants