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

SDRS circle depencendy if enabled = true is set #2775

Open
Blogshot opened this issue Jan 9, 2025 · 1 comment
Open

SDRS circle depencendy if enabled = true is set #2775

Blogshot opened this issue Jan 9, 2025 · 1 comment
Assignees

Comments

@Blogshot
Copy link

Blogshot commented Jan 9, 2025

I am experiencing an issue where I am trying to create a SDRS protection group, then add a server to it and have the protection group be enabled.

The issue seems to be that I am creating the protection group, which cannot be enabled yet because it's empty (has no opentelekomcloud_sdrs_protected_instance_v1). But to create a opentelekomcloud_sdrs_protected_instance_v1, I have to reference a opentelekomcloud_sdrs_protectiongroup_v1 which cannot be created because if is empty.

If I omit enabled = true from the config, terraform works but I have to enable the protection manually in the cloud console afterwards.

Terraform provider version

Terraform v1.9.8

Affected Resource(s)

opentelekomcloud_sdrs_protectiongroup_v1

Terraform Configuration Files

terraform {
  required_providers {
    opentelekomcloud = {
      source = "opentelekomcloud/opentelekomcloud"
      version = "1.36.28"
    }
  }
}

# Get the ID of the latest image
data "opentelekomcloud_images_image_v2" "win_server_image_id" {
  name = var.image_name
  most_recent = true
}

# Create a key
resource "opentelekomcloud_compute_keypair_v2" "create-keypair" {
  name = "redacted"
}

# Create Port with fixed IP
resource "opentelekomcloud_networking_port_v2" "create-port-1" {
 name = "port_1"
 admin_state_up = "true"
 network_id = "redacted"
 security_group_ids = "redacted"
 fixed_ip {
  subnet_id = "redacted"
  ip_address = var.access_ip
 }
}

# Create a server instance
resource "opentelekomcloud_compute_instance_v2" "create-instance" {
  name        = var.ecs_name
  region      = var.region
  availability_zone = var.az
  flavor_name = var.flavor_name
  key_pair = "redacted"

  #Boot Disk with OS Image
  block_device {
    uuid = data.opentelekomcloud_images_image_v2.win_server_image_id.id
    source_type = "image"
    volume_size = 120
    boot_index = 0
    destination_type = "volume"
    delete_on_termination = true
  }

  #DB Data Disk
  block_device {
    boot_index            = -1
    delete_on_termination = true
    destination_type      = "volume"
    source_type           = "blank"
    volume_size           = 2048
    volume_type           = "SSD"
  }

  #Log Disk
  block_device {
    boot_index            = -1
    delete_on_termination = true
    destination_type      = "volume"
    source_type           = "blank"
    volume_size           = 160
    volume_type           = "SSD"
  }

  #Network Card bound to the IP Port with the private and virtual IPs
  network {
    port = opentelekomcloud_networking_port_v2.create-port-1.id
    access_network = true
  }
}

# Artificial x second delay after ecs creation to allow for Administrator password output
resource "time_sleep" "wait_x_seconds" {
  depends_on = [opentelekomcloud_compute_instance_v2.create-instance]
  create_duration = "300s"
}

# setup SDRS for the new ecs
data "opentelekomcloud_sdrs_domain_v1" "dom_1" {}

resource "opentelekomcloud_sdrs_protectiongroup_v1" "group_1" {
  name        = "redacted"
  description = "Created by terraform"

  source_availability_zone = "eu-de-01"
  target_availability_zone = "eu-de-02"

  domain_id     = data.opentelekomcloud_sdrs_domain_v1.dom_1.id
  source_vpc_id = var.sdrs_prod
  enable        = true
}

resource "opentelekomcloud_sdrs_protected_instance_v1" "instance_1" {
  name                 = "redacted"
  description          = "Created by terraform"
  group_id             = opentelekomcloud_sdrs_protectiongroup_v1.group_1.id
  server_id            = opentelekomcloud_compute_instance_v2.create-instance.id
}

Debug Output/Panic Output

Visual Studio Code marks the line "enable = true" as Unexpected attribute: An attribute named "enable" is not expected here
image

Also, the error output is as follows:

module.otc-module.opentelekomcloud_sdrs_protectiongroup_v1.group_1: Creating...
╷
│ Error: error while enabling Protection Group: error enabling OpenTelekomcomCloud SDRS Protectiongroup: Bad request with: [POST https://sdrs.eu-de.otc.t-systems.com/v1/redacted/server-groups/redacted/action], error message: {"error":{"message":"Replication pair not found","code":"SDRS.1608"}}
│ 
│   with module.otc-module.opentelekomcloud_sdrs_protectiongroup_v1.group_1,
│   on ../terraform-common/otc-module-dbserver/main.tf line 92, in resource "opentelekomcloud_sdrs_protectiongroup_v1" "group_1":
│   92: resource "opentelekomcloud_sdrs_protectiongroup_v1" "group_1" {
│ 
╵

Steps to Reproduce

  1. terraform apply

Expected Behavior

The SRDS should be created and enabled

Actual Behavior

Terraform errors out if enabled = true

References

#2649

@anton-sidelnikov anton-sidelnikov self-assigned this Jan 10, 2025
@anton-sidelnikov
Copy link
Member

Hi @Blogshot, kindly ensure you’re using the latest provider version and set the dr_type = "migration" attribute in opentelekomcloud_sdrs_protectiongroup_v1. Everything is working as expected on my end. I used your configuration for opentelekomcloud_sdrs_protectiongroup_v1 without enable = "true" initially and then enabled it during the second apply.
image

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

No branches or pull requests

2 participants