citrix / terraform-provider-citrixadc

Part of NetScaler Automation Toolkit | https://github.com/netscaler/automation-toolkit
https://registry.terraform.io/providers/citrix/citrixadc
Apache License 2.0
119 stars 59 forks source link

[Bug]: Error "Operation already in progress" while trying to create multiple `citrixadc_ntpserver` resources #1150

Closed joachimBurket closed 6 months ago

joachimBurket commented 7 months ago

Terraform Core Version

v1.6.2

citrixadc Provider Version

v1.38.0

Operating system

RHEL 9.3 (Plow)

Affected Resource(s)

Equivalent NetScaler CLI Command

add ntp-server

Expected Behavior

When multiple citrixadc_ntpserver resources are specified in the .tf file, they are all created in the Netscaler

Actual Behavior

Only the first NTP server gets created, and the Terraform apply command fails

Relevant Error/Panic Output Snippet

Plan: 4 to add, 0 to change, 0 to destroy.
citrixadc_ntpserver.ntpserver3: Creating...
citrixadc_ntpserver.ntpserver1: Creating...
citrixadc_ntpserver.ntpserver2: Creating...
citrixadc_ntpserver.ntpserver4: Creating...
citrixadc_ntpserver.ntpserver4: Creation complete after 1s [id=172.20.12.12]
╷
│ Error: [ERROR] nitro-go: Failed to create resource of type ntpserver, name=172.20.12.13, err=failed: 599 Netscaler specific error ({ "errorcode": 293, "message": "Operation already in progress", "severity": "ERROR" })
│ 
│   with citrixadc_ntpserver.ntpserver1,
│   on main.tf line 85, in resource "citrixadc_ntpserver" "ntpserver1":
│   85: resource "citrixadc_ntpserver" "ntpserver1" {
│ 
╵
╷
│ Error: [ERROR] nitro-go: Failed to create resource of type ntpserver, name=172.20.12.14, err=failed: 599 Netscaler specific error ({ "errorcode": 293, "message": "Operation already in progress", "severity": "ERROR" })
│ 
│   with citrixadc_ntpserver.ntpserver2,
│   on main.tf line 90, in resource "citrixadc_ntpserver" "ntpserver2":
│   90: resource "citrixadc_ntpserver" "ntpserver2" {
│ 
╵
╷
│ Error: [ERROR] nitro-go: Failed to create resource of type ntpserver, name=172.20.12.15, err=failed: 599 Netscaler specific error ({ "errorcode": 293, "message": "Operation already in progress", "severity": "ERROR" })
│ 
│   with citrixadc_ntpserver.ntpserver3,
│   on main.tf line 95, in resource "citrixadc_ntpserver" "ntpserver3":
│   95: resource "citrixadc_ntpserver" "ntpserver3" {

### Terraform Configuration Files

```terraform

resource "citrixadc_ntpsync" "tf_ntpsync" {
  state = "ENABLED"
}
resource "citrixadc_ntpserver" "ntpserver1" {
  serverip           = "172.20.12.12"
  minpoll            = 6
  maxpoll            = 10
}
resource "citrixadc_ntpserver" "ntpserver2" {
  serverip           = "172.20.12.13"
  minpoll            = 6
  maxpoll            = 10
}
resource "citrixadc_ntpserver" "ntpserver3" {
  serverip           = "172.20.12.14"
  minpoll            = 6
  maxpoll            = 10
}
resource "citrixadc_ntpserver" "ntpserver4" {
  serverip           = "172.20.12.15"
  minpoll            = 6
  maxpoll            = 10
}

Steps to Reproduce

Launch terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

References

No response

rohit-myali commented 6 months ago

Hello @joachimBurket

Thanks for raising this issue.

As for as I can see, ntpsync and ntpserver, does not allow parallel execution. But if there is no dependency terraform tries to execute resources parallely. So, it is recommended to create dependencies among them.

For Example:

resource "citrixadc_ntpsync" "tf_ntpsync" {
  state = "ENABLED"
}
resource "citrixadc_ntpserver" "ntpserver1" {
  serverip   = "172.20.12.12"
  minpoll    = 6
  maxpoll    = 10
  depends_on = [citrixadc_ntpsync.tf_ntpsync]
}
resource "citrixadc_ntpserver" "ntpserver2" {
  serverip   = "172.20.12.13"
  minpoll    = 6
  maxpoll    = 10
  depends_on = [citrixadc_ntpserver.ntpserver1]
}
resource "citrixadc_ntpserver" "ntpserver3" {
  serverip   = "172.20.12.14"
  minpoll    = 6
  maxpoll    = 10
  depends_on = [citrixadc_ntpserver.ntpserver2]
}
resource "citrixadc_ntpserver" "ntpserver4" {
  serverip   = "172.20.12.15"
  minpoll    = 6
  maxpoll    = 10
  depends_on = [citrixadc_ntpserver.ntpserver3]
}
joachimBurket commented 6 months ago

Hi @rohit-myali,

Thanks a lot for your answer, it did the trick! :)

Maybe adding a note to the ntpsync and ntpserver documentation indicating this trick could help other terraform beginners in the future 😄

rohit-myali commented 6 months ago

Sure @joachimBurket

We will make a note if this to update our docs.!!