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
103 stars 118 forks source link

Monitor: destination port is ignored #319

Closed zbindenren closed 3 years ago

zbindenren commented 4 years ago

I have the following resource definition with the latest bigip provider:

"bigip_ltm_monitor" "test" { 
  ...
   destination = "*:7001"    
  ...
}             

Plan and apply works the first time but *:* (instead of *:7001) is set. When I change nothing in the config and run a plan again I get the following:

 resource "bigip_ltm_monitor" "test" {
 ...
      ~ destination    = "*:*" -> "*:7001"
 ...

And then of course the apply fails (because this is an immutable field).

focrensh commented 4 years ago

Are you using the latest provider for the example above?

focrensh commented 4 years ago

Tracking with TER-424

zbindenren commented 4 years ago

Are you using the latest provider for the example above?

Yes I am using: 1.3.0.

papineni87 commented 4 years ago

@zbindenren

I tried below monitor config, and destination port is set in bigip and also in the state file

resource "bigip_ltm_monitor" "monitor" { name = "/Common/terraform_monitor1" parent = "/Common/http" send = "GET /some/path123\r\n" timeout = "100" interval = "30" destination = "*:7003" }

Terraform will perform the following actions:

bigip_ltm_monitor.monitor will be created

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

image

Terraform State file

{ "version": 4, "terraform_version": "0.12.25", "serial": 29, "lineage": "b1aa906f-4f3c-5b48-25d6-ca105a518e06", "outputs": {}, "resources": [ { "mode": "managed", "type": "bigip_ltm_monitor", "name": "monitor", "provider": "provider.bigip", "instances": [ { "schema_version": 0, "attributes": { "adaptive": "disabled", "adaptive_limit": 200, "compatibility": "", "database": "", "defaults_from": "", "destination": "*:7003", "filename": "", "id": "/Common/terraform_monitor1",

I am using bigip provider version : 1.3.2 and bigip version 14.x , what is the bigip version you are using ?

papineni87 commented 4 years ago

@zbindenren are you still seeing the issue ?

lorinw commented 4 years ago

Same issue for me reproducible on 1.2 and 1.3. Noticed this after we upgraded to 15.0.1 Build 0.0.11.

1.) It shows it is going to apply with destination port :8200, but applies it with default 2.) The next plan/apply shows it needs to change it :8200, but then fails when trying to correct it.

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

Terraform will perform the following actions:

bigip_ltm_monitor.foo will be created

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

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

Enter a value: yes

bigip_ltm_monitor.foo: Creating... bigip_ltm_monitor.foo: Creation complete after 1s [id=/Common/monitor_foo] bigip_ltm_pool.pool_foo_8200: Modifying... [id=/Common/pool_foo_8200] bigip_ltm_pool.pool_foo_8200: Modifications complete after 1s [id=/Common/pool_foo_8200]

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

terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage.

data.foo_generic_secret.svc-f5-automation: Refreshing state... bigip_ltm_monitor.foo: Refreshing state... [id=/Common/monitor_foo] bigip_ltm_node.nodes[1]: Refreshing state... [id=/Common/ussl-foop02.bar.com] bigip_ltm_node.nodes[2]: Refreshing state... [id=/Common/ussl-foop03.bar.com] bigip_ltm_node.nodes[0]: Refreshing state... [id=/Common/ussl-foop01.bar.com] bigip_ltm_pool.pool_foo_8200: Refreshing state... [id=/Common/pool_foo_8200] bigip_ltm_pool_attachment.pool_foo_8200[0]: Refreshing state... [id=/Common/pool_foo_8200-/Common/ussl-foop01.bar.com:8200] bigip_ltm_pool_attachment.pool_foo_8200[2]: Refreshing state... [id=/Common/pool_foo_8200-/Common/ussl-foop03.bar.com:8200] bigip_ltm_pool_attachment.pool_foo_8200[1]: Refreshing state... [id=/Common/pool_foo_8200-/Common/ussl-foop02.bar.com:8200] bigip_ltm_virtual_server.https: Refreshing state... [id=/Common/vs_prod-foo_https]


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:

bigip_ltm_monitor.foo will be updated in-place

~ resource "bigip_ltm_monitor" "foo" { adaptive = "disabled" adaptive_limit = 200 ~ destination = ":" -> "*:8200" id = "/Common/monitor_foo" interval = 3 ip_dscp = 0 manual_resume = "disabled" name = "/Common/monitor_foo" parent = "/Common/https" receive = "200\sOK" reverse = "disabled" send = "GET /v1/sys/health HTTP/1.1\r\nHost: foo.bar.com\r\nConnection: close\r\n\r\n" time_until_up = 0 timeout = 5 transparent = "disabled" }

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

########### Next plan/apply ###########

terraform apply data.foo_generic_secret.svc-f5-automation: Refreshing state... bigip_ltm_monitor.foo: Refreshing state... [id=/Common/monitor_foo] bigip_ltm_node.nodes[1]: Refreshing state... [id=/Common/ussl-foop02.bar.com] bigip_ltm_node.nodes[0]: Refreshing state... [id=/Common/ussl-foop01.bar.com] bigip_ltm_node.nodes[2]: Refreshing state... [id=/Common/ussl-foop03.bar.com] bigip_ltm_pool.pool_foo_8200: Refreshing state... [id=/Common/pool_foo_8200] bigip_ltm_pool_attachment.pool_foo_8200[1]: Refreshing state... [id=/Common/pool_foo_8200-/Common/ussl-foop02.bar.com:8200] bigip_ltm_pool_attachment.pool_foo_8200[0]: Refreshing state... [id=/Common/pool_foo_8200-/Common/ussl-foop01.bar.com:8200] bigip_ltm_pool_attachment.pool_foo_8200[2]: Refreshing state... [id=/Common/pool_foo_8200-/Common/ussl-foop03.bar.com:8200] bigip_ltm_virtual_server.https: Refreshing state... [id=/Common/vs_prod-foo_https]

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:

bigip_ltm_monitor.foo will be updated in-place

~ resource "bigip_ltm_monitor" "foo" { adaptive = "disabled" adaptive_limit = 200 ~ destination = ":" -> "*:8200" id = "/Common/monitor_foo" interval = 3 ip_dscp = 0 manual_resume = "disabled" name = "/Common/monitor_foo" parent = "/Common/https" receive = "200\sOK" reverse = "disabled" send = "GET /v1/sys/health HTTP/1.1\r\nHost: foo.bar.com\r\nConnection: close\r\n\r\n" time_until_up = 0 timeout = 5 transparent = "disabled" }

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

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

Enter a value: yes

bigip_ltm_monitor.foo: Modifying... [id=/Common/monitor_foo]

Error: HTTP 400 :: {"code":400,"message":"\"compatibility\" invalid value \"none\", expected one of the following: \"disabled\" \"enabled\" ","errorStack":[],"apiError":26214401}

on monitors.tf line 1, in resource "bigip_ltm_monitor" "foo": 1: resource "bigip_ltm_monitor" "foo" {

Releasing state lock. This may take a few moments...

papineni87 commented 4 years ago

@lorinw I tried in bigip 15.0.1 and didn't see the issue and below is the config. Can you clone the latest repo and just try only monitor resource with below config, to see the issue coming or not ?

$ cat test.tf

provider "bigip" { address = "xxxxx" username = "xxxx" password = "xxx" }

resource "bigip_ltm_monitor" "monitor" { name = "/Common/terraform_monitor1" parent = "/Common/http" send = "GET /some/path123\r\n" timeout = "100" interval = "30" destination = "*:7003" }


$ terraform init

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work.

If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. HYD-ML-00064439:terraform-provider-bigip papineni$ terraform apply

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

Terraform will perform the following actions:

bigip_ltm_monitor.monitor will be created

Plan: 1 to add, 0 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

bigip_ltm_monitor.monitor: Creating... bigip_ltm_monitor.monitor: Creation complete after 7s [id=/Common/terraform_monitor1]

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

image

image

papineni87 commented 4 years ago

@lorinw , @zbindenren Pushed a fix for monitor dest port to master branch ( https://github.com/F5Networks/terraform-provider-bigip/pull/337 )

Can you clone the latest master branch and try the config again , let me know if the issue still persists .

papineni87 commented 4 years ago

$ terraform apply

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

Terraform will perform the following actions:

bigip_ltm_monitor.monitor_foo will be created

Plan: 1 to add, 0 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

bigip_ltm_monitor.monitor_foo: Creating... bigip_ltm_monitor.monitor_foo: Creation complete after 8s [id=/Common/monitor_foo]

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

zbindenren commented 4 years ago

I am currently on vacation. I will check it next week.

papineni87 commented 3 years ago

Issue fixed in 1.3.3 release