UpCloudLtd / terraform-provider-upcloud

Terraform provider for UpCloud
https://registry.terraform.io/providers/UpCloudLtd/upcloud
MIT License
61 stars 31 forks source link

The operation is not allowed while the server is in state 'maintenance'. (SERVER_STATE_ILLEGAL) #51

Closed nikohaap closed 4 years ago

nikohaap commented 6 years ago

The operation is not allowed while the server 00ee80de-d95d-4ed5-89e7-875d7a317c7d is in state 'maintenance'. (SERVER_STATE_ILLEGAL) The server was already up and running but it gave me that error. It occurs every now and than.

Error: Error applying plan:

1 error(s) occurred:

* upcloud_server.test (destroy): 1 error(s) occurred:

* upcloud_server.test: The operation is not allowed while the server 00ee80de-d95d-4ed5-89e7-875d7a317c7d is in state 'maintenance'. (SERVER_STATE_ILLEGAL)

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure

I tried to ran the plan again and it was a successfully

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

Terraform will perform the following actions:

  - upcloud_server.test

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

upcloud_server.test: Destroying... (ID: 00ee80de-d95d-4ed5-89e7-875d7a317c7d)
upcloud_server.test: Still destroying... (ID: 00ee80de-d95d-4ed5-89e7-875d7a317c7d, 10s elapsed)
upcloud_server.test: Destruction complete after 18s

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

I just changed the count from 1 to 0

resource "upcloud_server" "test" {
  count    = 0
  zone     = "nl-lia1"
  hostname = "nikoh-timeout-testing-${format("%04d", count.index + 1)}"

  cpu      = "2"
  mem      = "1024"

  # Login details
  login {
    user = "tf"

    keys = [
      "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZNKVSnDL5B+0DwqO04aQLmPKSy55kZ4vDNsKl2/YrI4qroICjWT0Hum89FuHv5HdEmpjWKRpyn06WLIi28C22LO5xDWUbnbsoNSiaNSC/CgKwZ/hu5fmScb0dAf+Va+KS42FEOGcSbAd36R2htRHnaLg4cgN2RjjQw8p5lfiVPl4zDtZr8+mZZKKPs6pxHY54mM5oTt+mqzfncwvnfF4tS498VY5kC4stqZAO1/A3rdP2YI7uIXP2bvQ4MSKohI9eoePTbuOCCZC7E20NA4uKxCeimGCciAusolp+1TrkDBmARF7ew/AI/X/R9d+tlZhcJ1QSx+oM9xhEuGEL6bxJ terraform@lianatech.com",
    ]

    create_password   = false
    password_delivery = "email"
  }

  storage_devices = [
    {
      # You can use both storage template names and UUIDs
      size    = 10
      action  = "clone"
      tier    = "maxiops"
      storage = "01000000-0000-4000-8000-000020040100"
    }
  ]
}
nikohaap commented 6 years ago

Hey, Can this somehow be related on the Upcloud API response. Since sometimes the control panel (web ui) shows that those instances would be in the maintenance state but refreshing the page shows that those are up and running. The use case is same kind of with the Terraform apply. At first apply run the Terraform gave me that error but with the second round it was successfull.

alienhaxor commented 6 years ago

Can you describe the steps for reproducing this error? You have a running server that you try to destroy and it returns "The operation is not allowed while the server x is in state 'maintenance'. (SERVER_STATE_ILLE GAL)" ?

PopoSensei commented 4 years ago

It seems that the problem here was that the server in question was in a state where it could not be deleted. E.g. Maintenance, Syncing or other. Unfortunately since the steps to reproduce this error have not been described I do not know for sure. Latest version of the provider will wait for storages and servers until their states are in a mode that can be deleted.

Will wait a while, if we get more information about this.

PopoSensei commented 4 years ago

Will now close this issue, since I can't reproduce with the latest version nor new information hasn't come to light.