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

terraform plan -detailed-exitcode return exit code despite non empty diff #36476

Open
Time0o opened this issue Feb 12, 2025 · 2 comments
Open
Labels
bug new new issue not yet triaged waiting for reproduction unable to reproduce issue without further information

Comments

@Time0o
Copy link

Time0o commented Feb 12, 2025

Terraform Version

Terraform v1.10.5

Terraform Configuration Files

variable "remote_ssh_user" {
  description = "SSH user for remote host"
  type        = string
}

variable "remote_ssh_host" {
  description = "Hostname for remote host"
  type        = string
}

variable "remote_ssh_private_key" {
  description = "Path to private key for connecting to remote host"
  type        = string
}

resource "tls_private_key" "vm_ssh_key" {
  algorithm = "ED25519"
}

resource "local_file" "vm_ssh_private_key_file" {
  filename        = "${path.module}/.ssh/id_ed25519"
  content         = tls_private_key.vm_ssh_key.private_key_pem
  file_permission = "0600"
}

terraform {
  required_providers {
    libvirt = {
      source = "dmacvicar/libvirt"
    }
  }
}

provider "libvirt" {
  # Remote connection to libvirtd via SSH
  uri = "qemu+ssh://${var.remote_ssh_user}@${var.remote_ssh_host}/system?keyfile=${var.remote_ssh_private_key}"
}

resource "libvirt_volume" "k8s_vm_disk" {
  name = "k8s-vm.qcow2"
  pool = "default"
  size = 10240 # 10 GiB
}

resource "libvirt_cloudinit_disk" "k8s_init" {
  name = "cloud-init.iso"
  user_data = templatefile("${path.module}/cloud-init/k8s.yaml", {
    ssh_public_key = tls_private_key.vm_ssh_key.public_key_openssh
  })
}

resource "libvirt_domain" "k8s_vm" {
  name   = "k8s-vm"
  memory = 2048 # 2 GiB
  vcpu   = 2

  disk {
    volume_id = libvirt_volume.k8s_vm_disk.id
  }

  network_interface {
    network_name = "default"
  }

  cloudinit = libvirt_cloudinit_disk.k8s_init.id
}

Debug Output

...debug output, or link to a gist...

Expected Behavior

tensorflow plan -detailed-exitcode prints:

Plan: 5 to add, 0 to change, 0 to destroy.

And should thus return exit code 2.

Actual Behavior

Exit code 0 is returned.

Steps to Reproduce

  1. terraform init
  2. terraform plan -out plan.tfplan -detailed-exitcode

Additional Context

I am running inside an Ubuntu 22.04 Docker container inside a GH Action workflow and am installing terraform via hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd.

References

No response

Generative AI / LLM assisted development?

No response

@Time0o Time0o added bug new new issue not yet triaged labels Feb 12, 2025
@crw
Copy link
Contributor

crw commented Feb 13, 2025

Thanks for this report!

@jbardin jbardin added the waiting for reproduction unable to reproduce issue without further information label Mar 24, 2025
@seh
Copy link

seh commented Mar 25, 2025

I am unable to reproduce this problem on macOS with any of Terraform versions 1.10.5, 1.11.1, or 1.11.2, but I experience it on the GitHub Actions runners as you describe using version 1.11.2.

This sounds reminiscent of actions/toolkit#1615. The current wrapper program gets the exit code from its call to exec.exec, which @vitorhugods says works fine in actions/toolkit#1615 (comment).

If I run the hashicorp/setup-terraform action with the terraform_wrapper parameter set to false, it works as expected, yielding the proper nonzero exit codes. That suggests that the wrapper program is either swallowing these nonzero exit codes or failing to retrieve the exit code properly.

[Time passes ....]

Oh, this problem is captured in hashicorp/setup-terraform#328.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new new issue not yet triaged waiting for reproduction unable to reproduce issue without further information
Projects
None yet
Development

No branches or pull requests

4 participants