vmware / terraform-provider-vmc

Terraform Provider for VMware Cloud on AWS
https://registry.terraform.io/providers/vmware/vmc/
Mozilla Public License 2.0
24 stars 27 forks source link

edrs settings are not truly "Optional" #76

Closed jontyq closed 2 years ago

jontyq commented 3 years ago

It appears that the new edrs settings are not truly optional.

This manifests when using a single node (1NODE) type SDDC.

Using a terraform config where there are no edrs settings defined, we get an error on an update run.

The initial create works fine for some reason, however a subsequent plan and apply tries to change the edrs settings. This then fails, because it tries to change them to the default which are invalid for 1NODE type.

Change seen in plan:

      ~ edrs_policy_type       = "cost" -> "storage-scaleup"                                                                                      
      ~ enable_edrs            = false -> true 

Error seen on apply:

Error:  Failed to update EDRS Policy: [Elastic DRS is not supported for sddc ff71f299-d38c-453d-9b19-97f2407f9f35, sddcType 1NODE, deployment type
 SingleAZ. (code)115 ]                                                                                                                            

  on module/SDDC/main.tf line 1, in resource "vmc_sddc" "this":                                                                                   
   1: resource "vmc_sddc" "this" {                                                                                                                                                                                                                                                  
saloneerege commented 3 years ago

Thanks for reporting this issue. We will look into it.

tlindsay42 commented 3 years ago

When attempting to disable eDRS with 2+ node clusters, the change is accepted but silently discarded, so the change is detected on every subsequent run.

saloneerege commented 3 years ago

When attempting to disable eDRS with 2+ node clusters, the change is accepted but silently discarded, so the change is detected on every subsequent run.

@tlindsay42 thanks for your feedback. Can you please elaborate on this scenario with exact steps ? This would help debug the issue.

tlindsay42 commented 3 years ago

Sure thing. Basic vmc_sddc resource with num_host > 1 and deployment_type = "SingleAZ". Set enable_edrs = false and terraform apply. The API will accept the request with no error. Run terraform apply again, and enable_edrs will be set to true again server side instead of false, so another change will be requested. If you apply the change again, the API will again accept the request, but not change the eDRS value.

I last confirmed this on a 3-node cluster scaled-out from a 1-node. I think I confirmed with "MultiAZ" as well last weekend, but not 100% certain now and unfortunately didn't save the output. Will try to test again if I get time.

tlindsay42 commented 3 years ago

First run

PS C:\sddc> get-date; terraform apply

Sunday, November 22, 2020 09:34:13
data.vmc_connected_accounts.account: Refreshing state... [id=[redacted]]
data.vmc_customer_subnets.subnets: Refreshing state... [id=[redacted]]
vmc_sddc.sddc: Refreshing state... [id=[redacted]]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # vmc_sddc.sddc will be updated in-place
  ~ resource "vmc_sddc" "sddc" {
        availability_zones     = [
            "us-east-1d",
        ]
        cloud_password         = "[redacted]"
        cloud_username         = "cloudadmin@vmc.local"
        cluster_id             = "6d665261-2e6f-4150-8320-d7e8ebd42989"
        cluster_info           = {
            "cluster_name"       = "Cluster-1"
            "cluster_state"      = "READY"
            "host_instance_type" = "i3.metal"
        }
        delay_account_link     = false
        deployment_type        = "SingleAZ"
        edrs_policy_type       = "storage-scaleup"
      ~ enable_edrs            = true -> false
        host_instance_type     = "I3_METAL"
        id                     = "4cfa4409-f55d-4ff3-8f33-b536bc0f6f17"
        max_hosts              = 16
        min_hosts              = 3
        nsxt_reverse_proxy_url = "[redacted]"
        num_host               = 3
        provider_type          = "AWS"
        region                 = "US_EAST_1"
        sddc_name              = "[redacted]"
        sddc_size              = {
            "nsx_size" = "medium"
            "vc_size"  = "medium"
        }
        sddc_state             = "READY"
        size                   = "medium"
        skip_creating_vxlan    = false
        sso_domain             = "vmc.local"
        vc_url                 = "[redacted]"
        vpc_cidr               = "10.2.0.0/16"
        vxlan_subnet           = "192.168.1.0/24"

        account_link_sddc_config {
            connected_account_id = "[redacted]"
            customer_subnet_ids  = [
                "[redacted]",
            ]
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

vmc_sddc.sddc: Modifying... [id=[redacted]]
vmc_sddc.sddc: Modifications complete after 7s [id=[redacted]]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Outputs:

available_vpc_subnet_ids = [
  "[redacted]",
]
cluster_info = {
  "cluster_name" = "Cluster-1"
  "cluster_state" = "READY"
  "host_instance_type" = "i3.metal"
}
connected_account_id = [redacted]
is_valid_vpc_subnet_ids = {
  "[redacted]" = true
}
management_virtual_appliance_size = {
  "nsx_size" = "medium"
  "vc_size" = "medium"
}
nsxt_reverse_proxy_url = [redacted]        
sddc_id = 4cfa4409-f55d-4ff3-8f33-b536bc0f6f17

Second run

PS C:\sddc> get-date; terraform apply

Sunday, November 22, 2020 09:34:32
data.vmc_connected_accounts.account: Refreshing state... [id=[redacted]]
data.vmc_customer_subnets.subnets: Refreshing state... [id=[redacted]]
vmc_sddc.sddc: Refreshing state... [id=[redacted]]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # vmc_sddc.sddc will be updated in-place
  ~ resource "vmc_sddc" "sddc" {
        availability_zones     = [
            "us-east-1d",
        ]
        cloud_password         = "[redacted]"
        cloud_username         = "cloudadmin@vmc.local"
        cluster_id             = "6d665261-2e6f-4150-8320-d7e8ebd42989"
        cluster_info           = {
            "cluster_name"       = "Cluster-1"
            "cluster_state"      = "READY"
            "host_instance_type" = "i3.metal"
        }
        delay_account_link     = false
        deployment_type        = "SingleAZ"
        edrs_policy_type       = "storage-scaleup"
      ~ enable_edrs            = true -> false
        host_instance_type     = "I3_METAL"
        id                     = "4cfa4409-f55d-4ff3-8f33-b536bc0f6f17"
        max_hosts              = 16
        min_hosts              = 3
        nsxt_reverse_proxy_url = "[redacted]"
        num_host               = 3
        provider_type          = "AWS"
        region                 = "US_EAST_1"
        sddc_name              = "[redacted]"
        sddc_size              = {
            "nsx_size" = "medium"
            "vc_size"  = "medium"
        }
        sddc_state             = "READY"
        size                   = "medium"
        skip_creating_vxlan    = false
        sso_domain             = "vmc.local"
        vc_url                 = "[redacted]"
        vpc_cidr               = "10.2.0.0/16"
        vxlan_subnet           = "192.168.1.0/24"

        account_link_sddc_config {
            connected_account_id = "[redacted]"
            customer_subnet_ids  = [
                "[redacted]",
            ]
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

vmc_sddc.sddc: Modifying... [id=[redacted]]
vmc_sddc.sddc: Modifications complete after 7s [id=[redacted]]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Outputs:

available_vpc_subnet_ids = [
  "[redacted]",
]
cluster_info = {
  "cluster_name" = "Cluster-1"
  "cluster_state" = "READY"
  "host_instance_type" = "i3.metal"
}
connected_account_id = [redacted]
is_valid_vpc_subnet_ids = {
  "subnet-54e3ce1e" = true
}
management_virtual_appliance_size = {
  "nsx_size" = "medium"
  "vc_size" = "medium"
}
nsxt_reverse_proxy_url = [redacted]        
sddc_id = 4cfa4409-f55d-4ff3-8f33-b536bc0f6f17
saloneerege commented 3 years ago

@tlindsay42 Thanks for your detailed response. We will look into it.

uprightvinyl commented 3 years ago

Using provider version 1.5.1, this error still occurs

resource "vmc_sddc" "sddc_a" {
  sddc_name           = "SDDC A"
  vpc_cidr            = "10.2.0.0/16"
  num_host            = 1
  provider_type       = "AWS"
  region              = "EU_WEST_1"
  delay_account_link  = false
  skip_creating_vxlan = true
  sso_domain          = "vmc.local"
  deployment_type     = "SingleAZ"
  sddc_type           = "1NODE"

  account_link_sddc_config {
    customer_subnet_ids  = [aws_subnet.sddc_a_connected_vpc_subnet[0].id]
    connected_account_id = data.vmc_connected_accounts.vmc_connected_account.id
  }
}
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # vmc_sddc.sddc_a will be updated in-place
  ~ resource "vmc_sddc" "sddc_a" {
      - edrs_policy_type       = "cost" -> null
        id                     = "53950c9f-cdec-4e4a-95fe-b7d914401b8a"
      - max_hosts              = 16 -> null
      - min_hosts              = 3 -> null
        # (22 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

vmc_sddc.sddc_a: Modifying... [id=53950c9f-cdec-4e4a-95fe-b7d914401b8a]

Error: EDRS policy cannot be updated for SDDC with type 1NODE

  on main.tf line 21, in resource "vmc_sddc" "sddc_a":
  21: resource "vmc_sddc" "sddc_a" {
Terraform v0.14.4
+ provider registry.terraform.io/adeleporte/hcx v0.3.4
+ provider registry.terraform.io/hashicorp/aws v3.27.0
+ provider registry.terraform.io/terraform-providers/vmc v1.5.1
uprightvinyl commented 3 years ago

@saloneerege Any thoughts on the above, are you able to recreate this issue?

saloneerege commented 3 years ago

@uprightvinyl Thanks for reporting this. @shylasrinivas can you look into this ?

carsonpadawon commented 2 years ago

I have run into the above issue. Can someone take a look and see how to resolve?

Error: EDRS policy cannot be updated for SDDC with type 1NODE

with vmc_sddc.sddc_1, on main.tf line 24, in resource "vmc_sddc" "sddc_1": 24: resource "vmc_sddc" "sddc_1" {

Terraform v1.2.9 on linux_amd64

dimitarproynov commented 2 years ago

The issue is caused by the behaviour of the SDDC properties: edrs_policy_type max_hosts min_hosts enable_edrs

Specifying them or not the provider assumed changes in these properties. On next run of "terraform apply" the code that checks for changes in the above properties was incorectly triggered and since the SDDC is 1NODE (that cannot change the above properties) the error was printed and execution stopped.

That behavior was fixed with: https://github.com/vmware/terraform-provider-vmc/pull/151

The fix will be out with the next version.

github-actions[bot] commented 3 weeks ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.