aliyun / terraform-provider-alicloud

Terraform AliCloud provider
https://www.terraform.io/docs/providers/alicloud/
Mozilla Public License 2.0
589 stars 553 forks source link

OperationFailed.ListenerStatusNotSupport when creating SLB rules #3253

Open choppedpork opened 3 years ago

choppedpork commented 3 years ago

Terraform Version

Terraform v0.14.5

Affected Resource(s)

Terraform Configuration Files

This SLB rule loop is part of a larger load balancer module I'm currently working on containing configs required to deploy my company's application. I can provide more of the code if needed - it seems like the issue might be around some of the specific settings here (more on that in the Actual Behaviour section below) .

resource "alicloud_slb_rule" "rule" {
  for_each = {
    for mapping in local.mappings : format("%s:%s", mapping.name, mapping.path) => mapping if mapping.settings.create_group
  }

  load_balancer_id = alicloud_slb.lb.id
  frontend_port    = alicloud_slb_listener.https.frontend_port
  name             = "${var.environment}-${var.name}-${replace(each.key, ":", "-")}" # terraform resource mappings look better with ':' but it's not an allowed character for rule names
  url              = each.value.path
  server_group_id  = alicloud_slb_server_group.group[each.value.name].id

  health_check              = "on"
  listener_sync             = "off" # override default healthcheck with service one
  health_check_http_code    = "http_2xx"
  health_check_interval     = 10
  health_check_uri          = each.value.settings.health_check_path
  health_check_connect_port = each.value.settings.health_check_port
  health_check_timeout      = 10
  healthy_threshold         = 3
  unhealthy_threshold       = 5

  sticky_session      = each.value.settings.stickiness ? "on" : "off"
  sticky_session_type = "server"
  cookie              = "SESSION"
}

Debug Output

Can provide if required.

Expected Behaviour

All load balancer rules created.

Actual Behaviour

When executing terraform apply some (but not all!) of the rules generated using the loop above throw this error:

Error: [ERROR] terraform-provider-alicloud/alicloud/resource_alicloud_slb_rule.go:350: Resource rule-7go0y2w91ejzn SetRule Failed!!! [SDK alibaba-cloud-sdk-go ERROR]:
SDK.ServerError
ErrorCode: OperationFailed.ListenerStatusNotSupport
Recommend: https://error-center.aliyun.com/status/search?Keyword=OperationFailed.ListenerStatusNotSupport&source=PopGw
RequestId: 8C4931E6-E179-4FA1-A68A-A04C4C96C107
Message: The status of the listener does not support this operation. Please try again later.

When applying terraform again, terraform detects that the rules have indeed been created but with incorrect settings - all the advanced features are missing:

  # module.lb.alicloud_slb_rule.rule["nginx:/foo/"] is tainted, so must be replaced
-/+ resource "alicloud_slb_rule" "rule" {
      - cookie_timeout               = 0 -> null
      + health_check                 = "on"
      ~ health_check_connect_port    = 0 -> 18100
      + health_check_http_code       = "http_2xx"
      ~ health_check_interval        = 0 -> 10
      ~ health_check_timeout         = 0 -> 10
      + health_check_uri             = "/foo/health"
      ~ healthy_threshold            = 0 -> 3
      ~ id                           = "rule-7gom5ge2n89or" -> (known after apply)
      ~ listener_sync                = "on" -> "off"
        name                         = "aliperf1-lb-nginx-/foo/"
      + scheduler                    = "wrr"
      + sticky_session               = "off"
      ~ unhealthy_threshold          = 0 -> 5
        # (5 unchanged attributes hidden)
    }

This is confirmed in the UI: image Note the missing (i) icon next to some of the rules - they should all have one. Applying the terraform plan again results in some of these being fixed - eventually all are applied correctly (it usually takes me 3-5 attempts to get all 17 rules listed here configured correctly).

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
choppedpork commented 3 years ago

@alibaba-oss just a gentle poke as it's been over a month..