F5Networks / terraform-provider-bigip

Terraform resources that can configure F5 BIG-IP products
https://registry.terraform.io/providers/F5Networks/bigip/latest/docs
Mozilla Public License 2.0
102 stars 117 forks source link

Big-IQ bigip_bigiq_as3 tenant resource removal/destruction fails with 500 error Cannot read property 'class' of null #959

Closed ghazalehca closed 1 month ago

ghazalehca commented 2 months ago

Environment

Application Services Version: 3.41 Big IP Provider Version: 1.21.0 BIG-IP Version: BIG-IP 17.1.0.2 Build 0.0.2 Point Release 2 Big-IQ Version: 8.3.0 Build 0.0.118

Summary

After creation of resource using bigip_bigiq_as3 ... (i.e., resource "bigip_bigiq_as3" "COMMON"), try destroying same resource by eliminating the resource from the definition.

Plan will say it will be destroyed, however, the deploy will result in the following error:

 Error: status:500, body:{"code":500,"message":"Cannot read property 'class' of null"}

Steps To Reproduce

Steps to reproduce the behavior:

  1. create application using bigip_bigiq_as3 resource where as3_json =
    
    {
    "class": "AS3",
    "action": "deploy",
    "persist": true,
    "declaration": {
    "class": "ADC",
    "target": {
        "address": "10.10.245.157"
    },
    "schemaVersion": "3.41.0",
    "Common": {
      "class": "Tenant",
      "Shared": {
        "class": "Application",
        "template": "shared",
        "constants": {
            "class": "Constants",
            "FLEX_TCP_PROFILE_SETTINGS": {
                "profileTCP": {
                    "ingress": {
                        "bigip": "/Common/Shared/AS3_FLEX_WAN_TCP_PROFILE"
                    },
                    "egress": {
                        "bigip": "/Common/Shared/AS3_FLEX_LAN_TCP_PROFILE"
                    }
                }
            }
        },
        "AS3_DEFAULT_ACCELERATION_PROFILE": {
          "class": "HTTP_Acceleration_Profile",
          "label": "DEFAULT DECLARATION"
        },
        "AS3_DEFAULT_HTTP_COMPRESSION_PROFILE": {
          "class": "HTTP_Compress",
          "label": "DEFAULT DECLARATION"
        },
        "AS3_FLEX_WAN_TCP_PROFILE": {
            "class": "TCP_Profile",
            "remark": "BDP = 100 ms, 1Gbps, doubled",
            "autoProxyBufferSize": false,
            "autoReceiveWindowSize": false,
            "autoSendBufferSize": false,
            "minimumRto": 200,
            "proxyBufferHigh": 25100000,
            "proxyBufferLow": 25000000,
            "pushFlag": "default",
            "receiveWindowSize": 12500000,
            "sendBufferSize": 12500000,
            "synRtoBase": 200
        },
        "AS3_FLEX_LAN_TCP_PROFILE": {
            "class": "TCP_Profile",
            "remark": "BDP = 1 MS, 10Gbps, doubled",
            "autoProxyBufferSize": false,
            "autoReceiveWindowSize": false,
            "autoSendBufferSize": false,
            "minimumRto": 2,
            "proxyBufferHigh": 2600000,
            "proxyBufferLow": 2500000,
            "pushFlag": "default",
            "receiveWindowSize": 1250000,
            "sendBufferSize": 1250000,
            "synRtoBase": 2
        }
      }
    }
    }
    }
Example resource code in terraform:

resource "bigip_bigiq_as3" "COMMON" {

Tenant for Common Shared Application

as3_json = file(...from above...) bigiq_address = var.bigiq_ip bigiq_user = var.bigiq_user bigiq_password = var.bigiq_pw bigiq_token_auth = false }


2. after successfully building the COMMON shared application, remove this resource from the code..

resource "bigip_bigiq_as3" "COMMON" {

Tenant for Common Shared Application

as3_json = file(...from above...)

bigiq_address = var.bigiq_ip

bigiq_user = var.bigiq_user

bigiq_password = var.bigiq_pw

bigiq_token_auth = false

}


this will result in the build plan showing:
![image](https://github.com/F5Networks/terraform-provider-bigip/assets/59851554/4d578893-c7ab-4fa8-aa60-c5ce7d770ce6)

3. terraform apply (deploy code).  

results in the following deploy error:

![image](https://github.com/F5Networks/terraform-provider-bigip/assets/59851554/5e02cabd-6017-4353-8342-124de8025b40)

### Expected Behavior
removal of this resource should result in the application and tenant being removed.  Note: this is COMMON so it shouldn't be removed.  However, the application (shared) should be removed.  

Also IMPORTANT note that this behavior is exactly the same if it's a tentant such as:  

resource "bigip_bigiq_as3" "tenant" { }

![image](https://github.com/F5Networks/terraform-provider-bigip/assets/59851554/4b17daf1-f086-4d1e-87cf-161b9284cf45)

### Actual Behavior
This is the COMMON tenant (above), so it shouldn't be removed.  However, the application (shared) should be removed.  

Also IMPORTANT note that this behavior is exactly the same if it's **any tentant** such as:  

resource "bigip_bigiq_as3" "tenant" { ... definition here ... }

and then remove via...

resource "bigip_bigiq_as3" "tenant" { ... definition here ... }


![image](https://github.com/F5Networks/terraform-provider-bigip/assets/59851554/4b17daf1-f086-4d1e-87cf-161b9284cf45)

In case you were curious if this occurs in other versions, I tested the same by changing the bigip provider to 1.14.0  
bigip = {
  source  = "F5Networks/bigip"
  # version = "~> 1.21.0"
  version = "~> 1.14.0" 
}


Version 1.14.0 results in a similar error when destroying:  

![image](https://github.com/F5Networks/terraform-provider-bigip/assets/59851554/1b9cc4c6-7982-4574-934f-0fce631a1261)

One final note is that if you remove a single application out of a multi-application tenant by sending the new declaration without that application (as long as it's not the last one in the declaration), it works just fine removing 1 of the applications.
pgouband commented 2 months ago

Hi,

Thanks for reporting. Added to the backlog and internal tracking ID for this request is: INFRAANO-1532.