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_backup_protected_vm - protection can now be suspended during destroy #27950

Merged
merged 10 commits into from
Jan 21, 2025

Conversation

katbyte
Copy link
Collaborator

@katbyte katbyte commented Nov 8, 2024

Description

add provider feature vm_backup_suspend_protection_and_retain_data_on_destroy

Change Log

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

  • provider - support for the vm_backup_suspend_protection_and_retain_data_on_destroy feature [GH-00000]

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 #0000

Note

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

Copy link

This PR is being labeled as "stale" because it has not been updated for 30 or more days.

If this PR is still valid, please remove the "stale" label. If this PR is blocked, please add it to the "Blocked" milestone.

If you need some help completing this PR, please leave a comment letting us know. Thank you!

@github-actions github-actions bot added the stale label Dec 16, 2024
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

Hey @katbyte, this looks nearly there except for the test. We'll have to do some work to get this over the finish line and that test passing. After the duplicate provider config is removed, we'll hit the following:

=== CONT  TestAccBackupProtectedVm_protectionSuspendedOnDestroy
    testcase.go:173: Step 4/4 error: Error running apply: exit status 1

        Error: setting protection to BackupsSuspended and retaining data for Protected Item (Subscription: "1a6092a6-137e-4025-9a7c-ef77f76f2c02"
        Resource Group Name: "acctestRG-backup-250107164527989173"
        Vault Name: "acctest-250107164527989173"
        Backup Fabric Name: "Azure"
        Protection Container Name: "iaasvmcontainer;iaasvmcontainerv2;acctestRG-backup-250107164527989173;acctestvm"
        Protected Item Name: "VM;iaasvmcontainerv2;acctestRG-backup-250107164527989173;acctestvm"): protecteditems.ProtectedItemsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="UserErrorOperationDeniedOnImmutableItem" Message="The Vault and Bakcup Item is in Immutable state where destructive operations are not supported. The Vault and Backup Item is immutable, hence operation is denied. Refer to the documentation to learn more: https://aka.ms/AB-ImmutableVaults-States "

    panic.go:629: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: setting protection to BackupsSuspended and retaining data for Protected Item (Subscription: "1a6092a6-137e-4025-9a7c-ef77f76f2c02"
        Resource Group Name: "acctestRG-backup-250107164527989173"
        Vault Name: "acctest-250107164527989173"
        Backup Fabric Name: "Azure"
        Protection Container Name: "iaasvmcontainer;iaasvmcontainerv2;acctestRG-backup-250107164527989173;acctestvm"
        Protected Item Name: "VM;iaasvmcontainerv2;acctestRG-backup-250107164527989173;acctestvm"): protecteditems.ProtectedItemsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="UserErrorOperationDeniedOnImmutableItem" Message="The Vault and Bakcup Item is in Immutable state where destructive operations are not supported. The Vault and Backup Item is immutable, hence operation is denied. Refer to the documentation to learn more: https://aka.ms/AB-ImmutableVaults-States "

--- FAIL: TestAccBackupProtectedVm_protectionSuspendedOnDestroy (242.82s)

@@ -1098,6 +1117,21 @@ provider "azurerm" {
`, r.baseWithOutProvider(data))
}

func (r BackupProtectedVmResource) protectionSuspendOnDestroy(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Copy link
Member

Choose a reason for hiding this comment

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

This block is causing issues with the test

=== CONT  TestAccBackupProtectedVm_protectionSuspendedOnDestroy
    testcase.go:173: Step 4/4 error: Error running pre-apply plan: exit status 1
        Error: Duplicate provider configuration
          on terraform_plugin_test.tf line 41:
          41: provider "azurerm" {
        A default (non-aliased) provider configuration for "azurerm" was already
        given at terraform_plugin_test.tf:31,1-19. If multiple configurations are
        required, set the "alias" argument for alternative configurations.
    panic.go:626: Error retrieving state, there may be dangling resources: exit status 1
        Error: Duplicate provider configuration
          on terraform_plugin_test.tf line 41:
          41: provider "azurerm" {
        A default (non-aliased) provider configuration for "azurerm" was already
        given at terraform_plugin_test.tf:31,1-19. If multiple configurations are
        required, set the "alias" argument for alternative configurations.
--- FAIL: TestAccBackupProtectedVm_protectionSuspendedOnDestroy (272.60s)

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

This test is still failing post review updates

=== CONT  TestAccBackupProtectedVm_protectionSuspendedOnDestroy
    testcase.go:173: Step 4/4 error: Error running apply: exit status 1

        Error: setting protection to BackupsSuspended and retaining data for Protected Item (Subscription: "1a6092a6-137e-4025-9a7c-ef77f76f2c02"
        Resource Group Name: "acctestRG-backup-250107164527989173"
        Vault Name: "acctest-250107164527989173"
        Backup Fabric Name: "Azure"
        Protection Container Name: "iaasvmcontainer;iaasvmcontainerv2;acctestRG-backup-250107164527989173;acctestvm"
        Protected Item Name: "VM;iaasvmcontainerv2;acctestRG-backup-250107164527989173;acctestvm"): protecteditems.ProtectedItemsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="UserErrorOperationDeniedOnImmutableItem" Message="The Vault and Bakcup Item is in Immutable state where destructive operations are not supported. The Vault and Backup Item is immutable, hence operation is denied. Refer to the documentation to learn more: https://aka.ms/AB-ImmutableVaults-States "

    panic.go:629: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: setting protection to BackupsSuspended and retaining data for Protected Item (Subscription: "1a6092a6-137e-4025-9a7c-ef77f76f2c02"
        Resource Group Name: "acctestRG-backup-250107164527989173"
        Vault Name: "acctest-250107164527989173"
        Backup Fabric Name: "Azure"
        Protection Container Name: "iaasvmcontainer;iaasvmcontainerv2;acctestRG-backup-250107164527989173;acctestvm"
        Protected Item Name: "VM;iaasvmcontainerv2;acctestRG-backup-250107164527989173;acctestvm"): protecteditems.ProtectedItemsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="UserErrorOperationDeniedOnImmutableItem" Message="The Vault and Bakcup Item is in Immutable state where destructive operations are not supported. The Vault and Backup Item is immutable, hence operation is denied. Refer to the documentation to learn more: https://aka.ms/AB-ImmutableVaults-States "

--- FAIL: TestAccBackupProtectedVm_protectionSuspendedOnDestroy (242.82s)

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

I figured out how to get this to work and it requires #27859 to be merged first. I've left a comment in line for what to do


data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Copy link
Member

Choose a reason for hiding this comment

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

Once #27859 is merged, we can update to use a new config here that uses an immutable vault as we can't suspend protection without an immutable vault.

Copy link
Collaborator

@sreallymatt sreallymatt left a comment

Choose a reason for hiding this comment

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

Thanks @mbfrahry / @katbyte - left 2 minor comments, and there seems to be a linting error

internal/provider/framework/config_test.go Outdated Show resolved Hide resolved
internal/provider/framework/config_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@sreallymatt sreallymatt left a comment

Choose a reason for hiding this comment

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

LGTM!

@stephybun stephybun merged commit d40831d into main Jan 21, 2025
33 checks passed
@stephybun stephybun deleted the kt/recserv-vm-backup-suspend branch January 21, 2025 10:02
@github-actions github-actions bot added this to the v4.17.0 milestone Jan 21, 2025
stephybun added a commit that referenced this pull request Jan 21, 2025
jackofallops added a commit that referenced this pull request Jan 31, 2025
* Update for #27950

* Update for #27824

* Update for #28592 #28583 #28599 #28590 #28453

* Update #28528

* Update for #27853

* Update CHANGELOG.md #28221

* Update for #27760

* Update CHANGELOG.md #28480

* Update CHANGELOG.md typo

* Update CHANGELOG.md #28372

* Update CHANGELOG.md for #26047

also alphabetised ENHANCEMENTS

* Update for #28146

* Update CHANGELOG.md #28013

* Update CHANGELOG.md for #28492

* Update CHANGELOG.md for #28648

* Update CHANGELOG.md for #28549

* Update for #28469 #28620

* prep for release

* i touched it last

---------

Co-authored-by: catriona-m <[email protected]>
Co-authored-by: jackofallops <[email protected]>
Co-authored-by: sreallymatt <[email protected]>
Co-authored-by: Matthew Frahry <[email protected]>
Co-authored-by: jackofallops <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants