opentelekomcloud / terraform-provider-opentelekomcloud

Terraform OpenTelekomCloud provider
https://registry.terraform.io/providers/opentelekomcloud/opentelekomcloud/latest
Mozilla Public License 2.0
85 stars 77 forks source link

Support Cascading Delete for Load Balancers #1351

Closed DanielHabenicht closed 3 years ago

DanielHabenicht commented 3 years ago

Description of the enhancement

The Documentation describes an option to delete the Load-Balancer and all its resources: "When you select cascade delete, listeners, backend server groups, backend servers, health checks, forwarding policies, forwarding rules, whitelists, and tags associated with the load balancer will be deleted."

https://docs.otc.t-systems.com/api/elb/elb_zq_fz_0006.html

It would be great if this could also be exposed to the terraform ressource like this:

resource "opentelekomcloud_lb_loadbalancer_v2" "cce_cluster_lb" {
  name          = "${var.root_name}-cce-cluster-loadbalancer"
  vip_subnet_id = var.subnet_subnet_id
  # Add a new option for cascading delete
  cascade_delete = true
}

Reason

For my current deployments we are creating Load-Balancers by annotating services, but after destroying the Service the Load-Balancer Backend Group is not always destroyed as well resulting in errors in the teardown:

module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 2m20s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 2m30s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 2m40s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 2m50s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 3m0s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 3m10s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 3m20s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 3m30s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 3m40s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 3m50s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 4m0s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 4m10s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 4m20s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 4m30s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 4m40s elapsed]
module.cce.opentelekomcloud_lb_loadbalancer_v2.cce_cluster_lb: Still destroying... [id=7e2a6c24-49b4-4f74-aa74-7cc5700d6a12, 4m50s elapsed]
2021/08/31 09:46:12 [DEBUG] POST https://gitlab.devops.telekom.de/api/v4/projects/19241/terraform/state/indicarus-dev-app?ID=76fcf026-1151-691d-dbb9-738e567667db
╷
│ Error: unable to delete loadbalancer 7e2a6c24-49b4-4f74-aa74-7cc5700d6a12: Expected HTTP response code [202 204] when accessing [DELETE https://vpc.eu-de.otc.t-systems.com/v2.0/lbaas/loadbalancers/7e2a6c24-49b4-4f74-aa74-7cc5700d6a12], but got 409 instead
│ {"NeutronError": {"type": "EntityInUse", "detail": "", "message": "pool db7027cf-0617-4a41-b189-481c08ca6439 is using this loadbalancer"}}
│ 
│ 

We could import everything before but a straightforward cascade option would be better. (Otherwise I would have to create some data source requests (:)

DanielHabenicht commented 3 years ago

Although its not described in the documentation page I would conclude that the cascade option is a simple ?cascade=true query parameter.

outcatcher commented 3 years ago

It can't be implemented ― this feature is not supported, documentation is going to be updated in the nearest future. So let's get some new data sources :smile:

DanielHabenicht commented 3 years ago

Mhm, just thought it through and it does not make any sense to import the listeners and backends because they are not managed by terraform anyway so I can't really delete them.

Any reason on why it's not supported anymore?

outcatcher commented 3 years ago

@DanielHabenicht As far as I know, it was removed due to someone accidentally removing all their infrastructure ¯\_(ツ)_/¯. Of the good news: we're implementing octavia-proxy now - it is going to have a cascading deletion functionality. Though it's hard to say when it will be integrated into the OTC exactly.