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

resource/aws_directory_service_directory: Deletion and sweeper refactoring #16653

Merged
merged 1 commit into from
Dec 17, 2020

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Dec 8, 2020

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

NONE

A few changes to handle some API oddities and improve sweeper behavior:

  • Add aws_db_instance to sweeper dependencies since MSSQL databases attached to directories can cause ClientException: Cannot delete the directory because it still has authorized applications errors
  • Implement multiple error handling in sweeper
  • Skip ErrCodeEntityDoesNotExistException errors on deletion to prevent real world issues with stale plans and since sometimes the DescribeDirectories API can return directories that will return this error on deletion

Output from acceptance test in AWS Commercial:

--- PASS: TestAccAWSDirectoryServiceDirectory_basic (1143.67s)
--- PASS: TestAccAWSDirectoryServiceDirectory_connector (1261.53s)
--- PASS: TestAccAWSDirectoryServiceDirectory_disappears (620.70s)
--- PASS: TestAccAWSDirectoryServiceDirectory_microsoft (1873.90s)
--- PASS: TestAccAWSDirectoryServiceDirectory_microsoftStandard (1734.15s)
--- PASS: TestAccAWSDirectoryServiceDirectory_tags (1178.94s)
--- PASS: TestAccAWSDirectoryServiceDirectory_withAliasAndSso (798.85s)

Output from sweeper in AWS Commercial:

2020/12/08 13:51:37 [DEBUG] Running Sweepers for region (us-west-2):
2020/12/08 13:51:37 [DEBUG] Running Sweeper (aws_workspaces_workspace) in region (us-west-2)
2020/12/08 13:51:39 [DEBUG] Running Sweeper (aws_workspaces_directory) in region (us-west-2)
2020/12/08 13:51:39 [DEBUG] Running Sweeper (aws_db_instance) in region (us-west-2)
...
2020/12/08 13:55:50 [DEBUG] Running Sweeper (aws_fsx_windows_file_system) in region (us-west-2)
2020/12/08 13:55:51 [DEBUG] Running Sweeper (aws_directory_service_directory) in region (us-west-2)
...
2020/12/08 17:27:50 Sweeper Tests ran successfully:
  - aws_workspaces_workspace
  - aws_workspaces_directory
  - aws_db_instance
  - aws_fsx_windows_file_system
  - aws_directory_service_directory
2020/12/08 17:27:50 [DEBUG] Running Sweepers for region (us-east-1):
2020/12/08 17:27:50 [DEBUG] Running Sweeper (aws_workspaces_workspace) in region (us-east-1)
2020/12/08 17:27:51 [DEBUG] Running Sweeper (aws_db_instance) in region (us-east-1)
2020/12/08 17:27:51 [DEBUG] Running Sweeper (aws_fsx_windows_file_system) in region (us-east-1)
2020/12/08 17:27:51 [DEBUG] Running Sweeper (aws_workspaces_directory) in region (us-east-1)
2020/12/08 17:27:51 [DEBUG] Running Sweeper (aws_directory_service_directory) in region (us-east-1)
2020/12/08 17:27:52 Sweeper Tests ran successfully:
  - aws_workspaces_workspace
  - aws_db_instance
  - aws_fsx_windows_file_system
  - aws_workspaces_directory
  - aws_directory_service_directory
ok    github.com/terraform-providers/terraform-provider-aws/aws 8918.345s

…oring

A few changes to handle some API oddities and improve sweeper behavior:

- Add `aws_db_instance` to sweeper dependencies since MSSQL databases attached to directories can cause ` ClientException: Cannot delete the directory because it still has authorized applications` errors
- Implement multiple error handling in sweeper
- Skip `ErrCodeEntityDoesNotExistException` errors on deletion to prevent real world issues with stale plans and since sometimes the `DescribeDirectories` API can return directories that will return this error on deletion

Output from acceptance test in AWS Commercial:

```
--- PASS: TestAccAWSDirectoryServiceDirectory_basic (1143.67s)
--- PASS: TestAccAWSDirectoryServiceDirectory_connector (1261.53s)
--- PASS: TestAccAWSDirectoryServiceDirectory_disappears (620.70s)
--- PASS: TestAccAWSDirectoryServiceDirectory_microsoft (1873.90s)
--- PASS: TestAccAWSDirectoryServiceDirectory_microsoftStandard (1734.15s)
--- PASS: TestAccAWSDirectoryServiceDirectory_tags (1178.94s)
--- PASS: TestAccAWSDirectoryServiceDirectory_withAliasAndSso (798.85s)
```

Output from sweeper in AWS Commercial:

```
2020/12/08 13:51:37 [DEBUG] Running Sweepers for region (us-west-2):
2020/12/08 13:51:37 [DEBUG] Running Sweeper (aws_workspaces_workspace) in region (us-west-2)
2020/12/08 13:51:39 [DEBUG] Running Sweeper (aws_workspaces_directory) in region (us-west-2)
2020/12/08 13:51:39 [DEBUG] Running Sweeper (aws_db_instance) in region (us-west-2)
...
2020/12/08 13:55:50 [DEBUG] Running Sweeper (aws_fsx_windows_file_system) in region (us-west-2)
2020/12/08 13:55:51 [DEBUG] Running Sweeper (aws_directory_service_directory) in region (us-west-2)
...
2020/12/08 17:27:50 Sweeper Tests ran successfully:
  - aws_workspaces_workspace
  - aws_workspaces_directory
  - aws_db_instance
  - aws_fsx_windows_file_system
  - aws_directory_service_directory
2020/12/08 17:27:50 [DEBUG] Running Sweepers for region (us-east-1):
2020/12/08 17:27:50 [DEBUG] Running Sweeper (aws_workspaces_workspace) in region (us-east-1)
2020/12/08 17:27:51 [DEBUG] Running Sweeper (aws_db_instance) in region (us-east-1)
2020/12/08 17:27:51 [DEBUG] Running Sweeper (aws_fsx_windows_file_system) in region (us-east-1)
2020/12/08 17:27:51 [DEBUG] Running Sweeper (aws_workspaces_directory) in region (us-east-1)
2020/12/08 17:27:51 [DEBUG] Running Sweeper (aws_directory_service_directory) in region (us-east-1)
2020/12/08 17:27:52 Sweeper Tests ran successfully:
  - aws_workspaces_workspace
  - aws_db_instance
  - aws_fsx_windows_file_system
  - aws_workspaces_directory
  - aws_directory_service_directory
ok    github.com/terraform-providers/terraform-provider-aws/aws 8918.345s
```
@bflad bflad requested a review from a team as a code owner December 8, 2020 22:47
@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/directoryservice tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Dec 8, 2020
@bflad bflad added the technical-debt Addresses areas of the codebase that need refactoring or redesign. label Dec 15, 2020
Copy link
Contributor

@anGie44 anGie44 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@bflad bflad added this to the v3.22.0 milestone Dec 17, 2020
@bflad bflad merged commit cfd4729 into master Dec 17, 2020
@bflad bflad deleted the t-aws_directory_service-directory-sweeper-fixes branch December 17, 2020 01:31
@ghost
Copy link

ghost commented Dec 18, 2020

This has been released in version 3.22.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Jan 16, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size/M Managed by automation to categorize the size of a PR. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
2 participants