Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Inconsistent success attaching block storage -- Instance is locked #482

Open
Jugbot opened this issue Apr 25, 2024 · 0 comments
Open
Assignees
Labels

Comments

@Jugbot
Copy link

Jugbot commented Apr 25, 2024

Describe the bug
I am creating a new instance and attaching a block storage device to the instance at the same time.

resource "vultr_instance" "nodejs_server" {
  plan      = var.nodejs_plan
  os_id     = 1743
  region    = var.region
  label     = "nodejs-backend"
  hostname  = var.hostname
  vpc2_ids  = [vultr_vpc2.my_vpc2.id]
  script_id = vultr_startup_script.setup_script.id
  lifecycle {
    replace_triggered_by = [
      terraform_data.always_run
    ]
  }
}

resource "vultr_startup_script" "setup_script" {
  name = "Server Setup"
  type = "boot"
  script = base64encode(templatefile("server_setup.sh", {
    repository_url  = var.REPOSITORY_URL
    mysql_user      = var.DB_USER
    mysql_password  = var.DB_PASSWORD
    mysql_host      = vultr_database.mysql_db.host
    mysql_port      = vultr_database.mysql_db.port
    mysql_db_schema = vultr_database_db.my_database_db.name
    email_name      = var.EMAIL_NAME
    email_password  = var.EMAIL_PASSWORD
    nginx_config    = file("nginx.conf")
  }))
}

resource "terraform_data" "always_run" {
  input = timestamp()
}

resource "vultr_dns_domain" "my_domain" {
  domain = var.hostname
  ip     = vultr_instance.nodejs_server.main_ip
}

# Block storage is for storing ssl certificates only
# This was implemented to circumvent rate limiting on certificate requests
resource "vultr_block_storage" "my_block_storage" {
  attached_to_instance = vultr_instance.nodejs_server.id
  region               = var.region
  block_type           = "high_perf"
  size_gb              = 1
  lifecycle {
    prevent_destroy = true
  }
}

I get this error

Error: error attaching block storage (9e616948-a562-47d4-8876-3fe205d4fb3d): {"error":"unable to attach: Server is currently locked","status":400}
with vultr_block_storage.my_block_storage
on vultr_instance.tf line 43, in resource "vultr_block_storage" "my_block_storage":
resource "vultr_block_storage" "my_block_storage" {

To Reproduce
I believe only the simultaneous creation of an instance and attaching a block storage device to that instance is relevant.

This sometimes succeeds, however.

Expected behavior
The attach operation should wait until the server is ready (not locked)

Desktop (please complete the following information where applicable:

  • OS: Ubuntu
  • Terraform 1.8
  • vultr provider 2.19.0
@Jugbot Jugbot added the bug label Apr 25, 2024
@optik-aper optik-aper self-assigned this Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants