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

provider - support for the recover_soft_deleted_backup_protected_vm feature #24157

Merged
merged 13 commits into from
May 9, 2024

Conversation

ziyeqf
Copy link
Contributor

@ziyeqf ziyeqf commented Dec 8, 2023

fix #24051

features expand

❯ go test -v ./internal/provider/ -run=TestExpand                      
=== RUN   TestExpandFeatures
    features_test.go:364: [DEBUG] Test Case: "Empty Block"
    features_test.go:364: [DEBUG] Test Case: "Complete Enabled"
    features_test.go:364: [DEBUG] Test Case: "Complete Disabled"
--- PASS: TestExpandFeatures (0.00s)
=== RUN   TestExpandFeaturesApiManagement
    features_test.go:434: [DEBUG] Test Case: "Empty Block"
    features_test.go:434: [DEBUG] Test Case: "Purge Soft Delete On Destroy and Recover Soft Deleted Api Management Enabled"
    features_test.go:434: [DEBUG] Test Case: "Purge Soft Delete On Destroy and Recover Soft Deleted Api Management Disabled"
--- PASS: TestExpandFeaturesApiManagement (0.00s)
=== RUN   TestExpandFeaturesAppConfiguration
    features_test.go:504: [DEBUG] Test Case: "Empty Block"
    features_test.go:504: [DEBUG] Test Case: "Purge Soft Delete On Destroy and Recover Soft Deleted App Configuration Enabled"
    features_test.go:504: [DEBUG] Test Case: "Purge Soft Delete On Destroy and Recover Soft Deleted App Configuration Disabled"
--- PASS: TestExpandFeaturesAppConfiguration (0.00s)
=== RUN   TestExpandFeaturesApplicationInsights
    features_test.go:569: [DEBUG] Test Case: "Empty Block"
    features_test.go:569: [DEBUG] Test Case: "Disable Generated Rule"
    features_test.go:569: [DEBUG] Test Case: "Enable Generated Rule"
--- PASS: TestExpandFeaturesApplicationInsights (0.00s)
=== RUN   TestExpandFeaturesCognitiveServices
    features_test.go:634: [DEBUG] Test Case: "Empty Block"
    features_test.go:634: [DEBUG] Test Case: "Purge on Destroy Enabled"
    features_test.go:634: [DEBUG] Test Case: "Purge on Destroy Disabled"
--- PASS: TestExpandFeaturesCognitiveServices (0.00s)
=== RUN   TestExpandFeaturesKeyVault
    features_test.go:739: [DEBUG] Test Case: "Empty Block"
    features_test.go:739: [DEBUG] Test Case: "Purge Soft Delete On Destroy and Recover Soft Deleted Key Vaults Enabled"
    features_test.go:739: [DEBUG] Test Case: "Purge Soft Delete On Destroy and Recover Soft Deleted Key Vaults Disabled"
--- PASS: TestExpandFeaturesKeyVault (0.00s)
=== RUN   TestExpandFeaturesTemplateDeployment
    features_test.go:804: [DEBUG] Test Case: "Empty Block"
    features_test.go:804: [DEBUG] Test Case: "Delete Nested Items During Deletion Enabled"
    features_test.go:804: [DEBUG] Test Case: "Delete Nested Items During Deletion Disabled"
--- PASS: TestExpandFeaturesTemplateDeployment (0.00s)
=== RUN   TestExpandFeaturesVirtualMachine
    features_test.go:922: [DEBUG] Test Case: "Empty Block"
    features_test.go:922: [DEBUG] Test Case: "Delete OS Disk Enabled"
    features_test.go:922: [DEBUG] Test Case: "Graceful Shutdown Enabled"
    features_test.go:922: [DEBUG] Test Case: "Skip Shutdown and Force Delete Enabled"
    features_test.go:922: [DEBUG] Test Case: "All Disabled"
--- PASS: TestExpandFeaturesVirtualMachine (0.00s)
=== RUN   TestExpandFeaturesVirtualMachineScaleSet
    features_test.go:1036: [DEBUG] Test Case: "Empty Block"
    features_test.go:1036: [DEBUG] Test Case: "Force Delete Enabled"
    features_test.go:1036: [DEBUG] Test Case: "Roll Instances Enabled"
    features_test.go:1036: [DEBUG] Test Case: "Scale In On Delete Disabled"
    features_test.go:1036: [DEBUG] Test Case: "All Fields Disabled"
--- PASS: TestExpandFeaturesVirtualMachineScaleSet (0.00s)
=== RUN   TestExpandFeaturesLogAnalyticsWorkspace
    features_test.go:1100: [DEBUG] Test Case: "Empty Block"
    features_test.go:1100: [DEBUG] Test Case: "Permanent Delete Enabled"
    features_test.go:1100: [DEBUG] Test Case: "Permanent Delete Disabled"
--- PASS: TestExpandFeaturesLogAnalyticsWorkspace (0.00s)
=== RUN   TestExpandFeaturesResourceGroup
    features_test.go:1165: [DEBUG] Test Case: "Empty Block"
    features_test.go:1165: [DEBUG] Test Case: "Prevent Deletion If Contains Resources Enabled"
    features_test.go:1165: [DEBUG] Test Case: "Prevent Deletion If Contains Resources Disabled"
--- PASS: TestExpandFeaturesResourceGroup (0.00s)
=== RUN   TestExpandFeaturesRecoveryServicesVault
    features_test.go:1230: [DEBUG] Test Case: "Empty Block"
    features_test.go:1230: [DEBUG] Test Case: "Purge Soft Delete On Destroy and Recover Soft Deleted Protected VM Enabled"
    features_test.go:1230: [DEBUG] Test Case: "Purge Soft Delete On Destroy and Recover Soft Deleted Protected VM Disabled"
--- PASS: TestExpandFeaturesRecoveryServicesVault (0.00s)
=== RUN   TestExpandFeaturesManagedDisk
    features_test.go:1295: [DEBUG] Test Case: "Empty Block"
    features_test.go:1295: [DEBUG] Test Case: "No Downtime Resize Enabled"
    features_test.go:1295: [DEBUG] Test Case: "No Downtime Resize Disabled"
--- PASS: TestExpandFeaturesManagedDisk (0.00s)
=== RUN   TestExpandFeaturesSubscription
    features_test.go:1343: [DEBUG] Test Case: "Empty Block"
    features_test.go:1343: [DEBUG] Test Case: "No Downtime Resize Enabled"
--- PASS: TestExpandFeaturesSubscription (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-azurerm/internal/provider	

@ziyeqf ziyeqf force-pushed the tengzh/recovery/soft_deleted_recover branch from ad42736 to ad0e160 Compare December 8, 2023 07:50
Copy link
Collaborator

@magodo magodo 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 this PR!
I've taken a look through and left some comments inline, but this is mostly looking good to me 👍

internal/features/user_flags.go Outdated Show resolved Hide resolved
internal/provider/features_test.go Outdated Show resolved Hide resolved
internal/provider/features_test.go Outdated Show resolved Hide resolved
@ziyeqf
Copy link
Contributor Author

ziyeqf commented Dec 11, 2023

image

@ziyeqf ziyeqf requested a review from magodo December 11, 2023 08:32
@ziyeqf ziyeqf requested a review from magodo December 11, 2023 10:31
@magodo magodo marked this pull request as ready for review December 12, 2023 01:57
Copy link
Collaborator

@magodo magodo left a comment

Choose a reason for hiding this comment

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

LGTM now!

@@ -255,6 +255,21 @@ func schemaFeatures(supportLegacyTestSuite bool) *pluginsdk.Schema {
},
},

"recovery_services_vault": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be plural

Suggested change
"recovery_services_vault": {
"recovery_services_vaults": {

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

We have a bunch of test failures:

can we please fix up all tests?

image

@ziyeqf
Copy link
Contributor Author

ziyeqf commented Feb 22, 2024

The service seems to have a new issue (Azure/azure-rest-api-specs#27869) and needs workaround on #24978

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

#24978 has been merged but i am still seeing test failures
image

@ziyeqf
Copy link
Contributor Author

ziyeqf commented Mar 22, 2024

#24978 has been merged but i am still seeing test failures image

Code updated and the tests pass now. I removed the change on site_recovery_xxx files, as it should not be involved.
image

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

the tests for this also still seem quite flakey?
image

@@ -199,6 +205,12 @@ The `resource_group` block supports the following:

---

The `recovery_services_vault` block supports the following:

* `recover_soft_deleted_backup_protected_vm` - (Optional) Should the `azurerm_backup_protected_vm` resource recover a Soft-Deleted protected VM? Defaults to `true`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should default to false?

"recover_soft_deleted_backup_protected_vm": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is going to change the existing behaviour?

Suggested change
Default: true,
Default: false,

@ziyeqf
Copy link
Contributor Author

ziyeqf commented Apr 19, 2024

recover_soft_deleted_backup_protected_vm

TBH these tests on main branch are also flakey..

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

This doesn't seem to be a flakey test failure:

------- Stdout: -------
=== RUN   TestAccBackupProtectedVm_updateBackupPolicyId
=== PAUSE TestAccBackupProtectedVm_updateBackupPolicyId
=== CONT  TestAccBackupProtectedVm_updateBackupPolicyId
    testcase.go:113: Step 1/5 error: Error running pre-apply refresh: exit status 1
        
        Error: Duplicate provider configuration
        
          on terraform_plugin_test.tf line 26:
          26: provider "azurerm" {
        
        A default (non-aliased) provider configuration for "azurerm" was already
        given at terraform_plugin_test.tf:21,1-19. If multiple configurations are
        required, set the "alias" argument for alternative configurations.
    testing_new.go:79: Error retrieving state, there may be dangling resources: exit status 1
        
        Error: Duplicate provider configuration
        
          on terraform_plugin_test.tf line 26:
          26: provider "azurerm" {
        
        A default (non-aliased) provider configuration for "azurerm" was already
        given at terraform_plugin_test.tf:21,1-19. If multiple configurations are
        required, set the "alias" argument for alternative configurations.
--- FAIL: TestAccBackupProtectedVm_updateBackupPolicyId (5.44s)
FAIL

Should be good to merge once the test is fixed

@ziyeqf
Copy link
Contributor Author

ziyeqf commented May 7, 2024

uh...my fault. updated

❯❯ tftest recoveryservices TestAccBackupProtectedVm_updateBackupPolicyId
=== RUN   TestAccBackupProtectedVm_updateBackupPolicyId
=== PAUSE TestAccBackupProtectedVm_updateBackupPolicyId
=== CONT  TestAccBackupProtectedVm_updateBackupPolicyId
--- PASS: TestAccBackupProtectedVm_updateBackupPolicyId (877.88s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices      879.994s

@katbyte katbyte changed the title azurerm_backup_protected_vm - support recover soft deleted vm provider - support for the recover_soft_deleted_backup_protected_vm feature May 9, 2024
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 📨

@katbyte katbyte merged commit d6cf769 into hashicorp:main May 9, 2024
33 checks passed
katbyte added a commit that referenced this pull request May 9, 2024
@github-actions github-actions bot added this to the v3.103.0 milestone May 9, 2024
@ziyeqf ziyeqf deleted the tengzh/recovery/soft_deleted_recover branch May 10, 2024 01:45
Copy link

github-actions bot commented Jun 9, 2024

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 Jun 9, 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.

Support for azurerm_backup_protected_vm features backup_vault recover_soft_deleted_backup
3 participants