juju / terraform-provider-juju

A Terraform provider for Juju
Apache License 2.0
19 stars 32 forks source link

Terraform apply hangs indefinitely with `vertex "root" is waiting for "provider[...` #482

Open andersson1234 opened 1 month ago

andersson1234 commented 1 month ago

Description

Please find the .tf file attached!

terraform plan and terraform apply hang forever, with these logs:

2024-05-08T10:32:10.797Z [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/juju/juju\"] (close)" is waiting for "juju_application.autopkgtest-web (expand)"
2024-05-08T10:32:10.797Z [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/juju/juju\"] (close)"
2024-05-08T10:32:10.810Z [TRACE] dag/walk: vertex "juju_application.autopkgtest-web (expand)" is waiting for "provider[\"registry.terraform.io/juju/juju\"]"
2024-05-08T10:32:15.798Z [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/juju/juju\"] (close)"
2024-05-08T10:32:15.798Z [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/juju/juju\"] (close)" is waiting for "juju_application.autopkgtest-web (expand)"
2024-05-08T10:32:15.811Z [TRACE] dag/walk: vertex "juju_application.autopkgtest-web (expand)" is waiting for "provider[\"registry.terraform.io/juju/juju\"]"

changing the provider version to 0.8.0, makes this hanging stop happening. terraform plan fails in this case, as this specific config is bunk, but the hanging no longer happens.

Here's a link to the charm in question: https://charmhub.io/ubuntu-release-autopkgtest-web

My apologies if this bug isn't verbose enough. I'm new to terraform, and the juju provider but was told I should report this here :)

Urgency

Casually reporting

Terraform Juju Provider version

0.8.0

Terraform version

Terraform version: 1.8.2 dev

Juju version

agent-version: 2.9.44, deb-version: 2.9.49-ubuntu-amd64, controller-model-version is unauthorised.

Terraform Configuration(s)

terraform {
  required_version = ">= 1.0"
  required_providers {
    juju = {
      version = "0.12.0"
      source  = "juju/juju"
    }
  }
}

provider "juju" {}

variable "stage_name" {
  type = string
}

locals {
    # releases = var.stage_name == "production" ? "trusty xenial bionic focal jammy mantic noble" : "focal jammy mantic noble"
    channel = var.stage_name == "production" ? "latest/stable" : "latest/edge"
    http_proxy = "http://squid.internal:3128"
    https_proxy = "http://squid.internal:3128"
    no_proxy = "127.0.0.1,127.0.1.1,login.ubuntu.com,localhost,localdomain,novalocal,internal,archive.ubuntu.com,ports.ubuntu.com,security.ubuntu.com,ddebs.ubuntu.com,changelogs.ubuntu.com,keyserver.ubuntu.com,launchpadlibrarian.net,launchpadcontent.net,launchpad.net,10.24.0.0/24,keystone.ps5.canonical.com,objectstorage.prodstack5.canonical.com"
    # series = "focal"
    hostname = var.stage_name == "production" ? "autopkgtest.ubuntu.com" : "autopkgtest.staging.ubuntu.com"
    local_dir = var.stage_name == "production" ? "/home/prod-proposed-migration-environment/.local/share/mojo/LOCAL/autopkgtest-cloud/" : "/home/stg-proposed-migration-environment/.local/share/mojo/LOCAL/autopkgtest-cloud"
    storage_host_internal = "objectstorage.prodstack5.canonical.com:443"
    storage_path_internal = var.stage_name == "production" ? "dummy-value"
    model_name = var.stage_name == "production" ? "prod-proposed-migration-environment" : "stg-proposed-migration-environment"
}

resource "juju_application" "autopkgtest-web" {
  name = "autopkgtest-web"

  model = local.model_name

  charm {
    name     = "ubuntu-release-autopkgtest-web"
    channel  = local.channel
    base     = "ubuntu@20.04"
  }
  units = 1

  config = {
    hostname = local.hostname
    allowed-requestor-teams = <<-EOT
        autopkgtest-requestors
        canonical-foundations
        canonical-kernel-distro-team
        canonical-partner-eng
        canonical-security
        canonical-server
        canonical-ubuntu-qa
        EOT
    storage-url-internal = "https://${local.storage_host_internal}${local.storage_path_internal}"
    github-secrets = file("${local.local_dir}/${var.stage_name}/github-secrets.json")
    github-status-credentials = file("${local.local_dir}/${var.stage_name}/github-status-credentials.txt")
    swift-web-credentials = file("${local.local_dir}/${var.stage_name}/swift-web-credentials.conf")
    public-swift-creds = file("${local.local_dir}/${var.stage_name}/public-swift-creds")
    external-web-requests-api-keys = file("${local.local_dir}/${var.stage_name}/external-web-requests-api-keys.json")
    http-proxy = local.http_proxy
    https-proxy = local.https_proxy
    no-proxy = local.no_proxy
    cookies = "S0 S1"
    indexed-packages-fp = "/home/ubuntu/indexed-packages.json"
  }
}

Reproduce / Test

terraform init && terraform apply
# change version from 0.12.0 to 0.8.0
terraform init && terraform apply

Debug/Panic Output

No response

Notes & References

No response