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

opentelekomcloud_rds_instance_v3 - restoring to original instance deletes instance incl. backups and ends in instance creation loop #2238

Closed
reiSh6phoo9o opened this issue Jul 25, 2023 · 4 comments
Assignees

Comments

@reiSh6phoo9o
Copy link

reiSh6phoo9o commented Jul 25, 2023

Terraform provider version

provider registry.terraform.io/opentelekomcloud/opentelekomcloud v1.35.3

Affected Resource(s)

  • opentelekomcloud_rds_instance_v3

Terraform Configuration Files

resource "opentelekomcloud_rds_instance_v3" "main" {
  name                   = "test-rds"
  availability_zone = var.availability_zone

  db {
    password = random_password.main.result
    type         = var.db_type
    version    = var.db_version
    port         = local.db_port
  }

  security_group_id = opentelekomcloud_networking_secgroup_v2.main.id
  subnet_id              = data.opentelekomcloud_vpc_subnet_v1.private.id
  vpc_id                   = data.opentelekomcloud_vpc_v1.default.id
  flavor                     = var.flavor

  volume {
    type              = var.volume_type
    size               = var.volume_size_gb
  }
 
  # add this only after the instance has been created:
  restore_point {
    instance_id = "<id of this instance>"
    backup_id   = "<id of automated backup of this instance>"
  }
}

Steps to Reproduce

  1. terraform apply without restore_point block -> creates the instance
  2. terraform apply with additional restore_point block

Expected Behavior

From docs here: https://docs.otc.t-systems.com/relational-database-service/umn/working_with_rds_for_mysql/backups_and_restorations/restoring_from_backup_files_to_db_instances.html#procedure , I assume that I can restore to the original instance.
From docs here: https://registry.terraform.io/providers/opentelekomcloud/opentelekomcloud/latest/docs/resources/rds_instance_v3#restore_point , I can not see any constraints.

When adding a restore_point block to an existing opentelekomcloud_rds_instance_v3, I expect this to trigger a "Restore to Original". That is, it should not destroy the original instance, nor delete all automated backups.

Alternativly, the provider docs should clearly document, that:

  • adding a restore_point block triggers instance replacment, thus deleting automated backups
  • thus its not possible to restore to original instance using terraform
  • thus this block basically is only useful on instance creation

Actual Behavior

tf apply triggers an instance replacement, thus:

  • deletes the original instance
  • deletes all automated backups associated with that instance
  • provisions a new instance and tries to apply the backup on it
  • this leads to a loop, the web console shows: "Single task exception. The system is trying again."
  • propably because the backup it tries to apply is deleted in the previous step
  • so finally, my original database and all associated backus are gone, and I'm stuck in an instance creation loop
@anton-sidelnikov anton-sidelnikov self-assigned this Jul 25, 2023
@anton-sidelnikov
Copy link
Member

anton-sidelnikov commented Jul 25, 2023

Hello @reiSh6phoo9o, no, you do all procedure wrong, please read documentation carefully. Yes you can restore RDS but it must be another RDS instance.
If you apply

  restore_point {
    instance_id = "<id of this instance>"
    backup_id   = "<id of automated backup of this instance>"
  }

to existing one, so now you know the result.

From documentation:
image
If you point existing instance it will become unavailable

Never use terraform with auto-approve key, terraform always informs you about force recreation, it always means that resource will be destroyed.

@reiSh6phoo9o
Copy link
Author

Hi @anton-sidelnikov ,

thanks for looking into this.

From what you tell, and what I found out myself, I agree, that it is not possible to restore to the same instance (aka "restore to original", as it is called in otc docs) using terraform.

I disagree, that the documentation tells anything about it. Docs list three methods for restoration: restore to original, restore to existing, restore to new. The screenshot you took documents the "restore to existing", which refers to : restoring to another, already existing rds.

The method "restore to original" is documented like that:

grafik

From this, and from my experience using OTC webconsole, it is clearly possible and supported to restore a running RDS to an earlier point in time, without replacing the instance.

The thing I ask, is two things:

First, feature request: would love to see, that I can restore a RDS to a earlier point in time, as I can do using the webconsole.

Second: if that's not possible: would love to see some hints in the provider documentation, that the method "restore to original" is not possible using terraform.

Thanks!

@anton-sidelnikov
Copy link
Member

Hi @reiSh6phoo9o, yes I agree, we will update documentation first, then will think how to implement another options for restoration, currently from provider you can only restore to another instance.

otc-zuul bot pushed a commit that referenced this issue Oct 11, 2023
[RDS]: `opentelekomcloud_rds_instance_v3` restore to point

Summary of the Pull Request
Feature to restore backups to an existing rds v3 instance.
PR Checklist

 Refers to: #2238
 Tests added/passed.
 Documentation updated.
 Schema updated.
 Release notes added.

Acceptance Steps Performed
=== RUN   TestAccRdsPostgre13V3ParamsBasic
--- PASS: TestAccRdsPostgre13V3ParamsBasic (478.33s)
PASS

Process finished with the exit code 0

=== RUN   TestAccRdsInstanceV3ElasticIP
--- PASS: TestAccRdsInstanceV3ElasticIP (752.79s)
PASS

Process finished with the exit code 0

=== RUN   TestAccRdsInstanceV3Basic
--- PASS: TestAccRdsInstanceV3Basic (850.40s)
PASS

Process finished with the exit code 0

=== RUN   TestAccRdsInstanceV3RestoreToPITR
--- PASS: TestAccRdsInstanceV3RestoreToPITR (670.13s)
PASS

Process finished with the exit code 0

Reviewed-by: Vladimir Vshivkov
Reviewed-by: Aloento
Reviewed-by: Anton Sidelnikov
@artem-lifshits
Copy link
Member

@reiSh6phoo9o feature added and documentation updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants