IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
340 stars 662 forks source link

ibm_container_alb_create doesn't create more than one ALB during apply #4886

Open Borys-Kuncewicz opened 10 months ago

Borys-Kuncewicz commented 10 months ago

Community Note

Terraform CLI and Terraform IBM Provider Version

Terraform v0.13.5 IBM Provider 1.50.0

Affected Resource(s)

Terraform Configuration Files

resource "ibm_container_alb_create" "dal10_alb" {
  cluster  = ibm_container_cluster.cluster.id
  enable   = true
  alb_type = "private"
  vlan_id  = ibm_network_vlan.dal10_private_vlan.id
  zone     = "dal10"
}

resource "ibm_container_alb_create" "dal12_alb" {
  cluster  = ibm_container_cluster.cluster.id
  enable   = true
  alb_type = "private"
  vlan_id  = ibm_network_vlan.dal12_private_vlan.id
  zone     = "dal12"
}

Expected Behavior

Terraform should have created two ALBs.

Actual Behavior

Terraform created both ALBs with the same ID, resulting in dal10 ALB overwritting DAL12 ALB. Finally there's only one ALB created.

ibm_container_alb_create.d12_private: Creation complete after 3s [id=private-xxxxxxxxx-alb7] ibm_container_alb_create.d10_private: Creation complete after 3s [id=private-xxxxxxxxx-alb7]

Steps to Reproduce

hkantare commented 10 months ago

@attilatabori Can you look into this

hkantare commented 10 months ago

As a workaround can we run creation of alb in sequential way by adding depends_on

resource "ibm_container_alb_create" "dal10_alb" {
  cluster  = ibm_container_cluster.cluster.id
  enable   = true
  alb_type = "private"
  vlan_id  = ibm_network_vlan.dal10_private_vlan.id
  zone     = "dal10"
}

resource "ibm_container_alb_create" "dal12_alb" {
 depends_on = [ibm_container_alb_create.dal10_alb]
  cluster  = ibm_container_cluster.cluster.id
  enable   = true
  alb_type = "private"
  vlan_id  = ibm_network_vlan.dal12_private_vlan.id
  zone     = "dal12"
}
attilatabori commented 10 months ago

The issue seems is not in the terraform provider, but beyond the API. Internal issue raised and investagtion ongoing.

blacksd commented 9 months ago

It looks like a synchronization problem; we've seen that in the past for kp, but I couldn't find a reference (sorry).

Also, it looks like the destruction is not working either:

module.this.ibm_container_alb_create.private["osa22"]: Destroying... [id=private-crcOMISSIS-alb4]
module.this.ibm_container_alb_create.private["osa23"]: Destroying... [id=private-crcOMISSIS-alb4]
module.this.ibm_container_alb_create.private["osa21"]: Destroying... [id=private-crcOMISSIS-alb4]
module.this.ibm_container_alb_create.private["osa23"]: Destruction complete after 0s
module.this.ibm_container_alb_create.private["osa21"]: Destruction complete after 0s
module.this.ibm_container_alb_create.private["osa22"]: Destruction complete after 0s
Releasing state lock. This may take a few moments...

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

but

❯ ibmcloud ks ingress alb ls -c OMISSIS | awk 'NR==2 || /alb4/ {print $0}'
ALB ID                                Enabled   State     Type      ALB IP          Zone    Build            ALB VLAN ID   NLB Version   Status
private-crcOMISSIS-alb4               true      enabled   private   10.8.18.4       osa21   1.8.4_5644_iks   3241682       1.0           healthy

ALBs cannot be destroyed at all, only disabled.

attilatabori commented 9 months ago

once the ALB-s are created, it cannot be destroyed, only disable them. It is also under refactor. But currently there is no way to get rid of them.

szombi commented 9 months ago

Hello!

@Borys-Kuncewicz can you retry this now? We released a possible ALB create fix. Thanks!