Open sameer666 opened 2 years ago
Hi @sameer666, thanks for reporting this issue! I've got a few questions to help us debug and reproduce this problem.
It looks like the CTS configuration and generated Terraform configuration you've provided is the working config since it has the backend set to local. Could you update the CTS config and main.tf
with the files where Consul is the backend?
Is the session in the error message an empty string or have you redacted the actual value? Could you edit the removed values to be <redacted>
so that we can distinguish them from empty strings?
Can you give an overview of your Consul setup and would you be able to share any relevant Consul logs for the 500 error?
Consul has a list of situations where the session is invalidated here. Do you think any of these scenarios could be happening while you are running CTS?
Is the error happening when CTS is first started or is it happening while CTS is running after initialization has completed?
Thanks for the clarifications! Nothing is standing out to me as the root cause of your issue, and I haven't been able to reproduce it. Here are some debugging steps you could try next:
sync-tasks/<taskname>
consul kv get consul-terraform-sync/terraform-env:<taskname>
task {
name = "test-task"
source = "mkam/hello/cts"
providers = ["local"]
services = ["web"]
}
Describe the bug
When not setting the backend manually in driver "terraform" block, it sets it as consul. When trying to execute the task, Terraform is trying to acquire the state lock but it is failing with the following error:
On setting the backend as local, the execution works as expected.
When trying to run the module directly instead of through consul terraform sync, it works with the backend set as consul.
Versions
Consul Terraform Sync
Consul Version
Terraform Version
Configuration File(s)
using CTS to monitor 2 services in consul and call a module to create dynamic object mapping on Cisco FMC
```hcl log_level = "DEBUG" consul { address =Terraform Configuration Files Generated by Consul-Terraform-Sync
Click to toggle contents of main.tf
```terraform # This file is generated by Consul Terraform Sync. # # The HCL blocks, arguments, variables, and values are derived from the # operator configuration for Sync. Any manual changes to this file # may not be preserved and could be overwritten by a subsequent update. # # Task: web # Description: update policies based on node availability terraform { required_version = ">= 0.13.0, < 1.1.0" required_providers { fmc = { source = "CiscoDevNet/fmc" version = "0.2.1" } } backend "consul" { address =Click to toggle contents of terraform.tfvars
```terraform # This file is generated by Consul Terraform Sync. # # The HCL blocks, arguments, variables, and values are derived from the # operator configuration for Sync. Any manual changes to this file # may not be preserved and could be overwritten by a subsequent update. # # Task: web # Description: update policies based on node availability services = { "api.ip-1-1-1-1.dc1" = { id = "api" name = "api" kind = "" address = "1.1.1.1" port = 9090 meta = {} tags = [] namespace = "" status = "passing" node = "ip-1-1-1-1" node_id = "" node_address = "1.1.1.1" node_datacenter = "dc1" node_tagged_addresses = { lan = "1.1.1.1" lan_ipv4 = "1.1.1.1" wan = "1.1.1.1" wan_ipv4 = "1.1.1.1" } node_meta = { consul-network-segment = "" } cts_user_defined_meta = {} }, } ```Expected Behavior
Task gets executed and dynamic objects are updated with the new mappings of IP Addresses
Actual Behavior
Task is not getting executed with the error Error acquiring the state lock when executing task