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

Persistent disk images not deleted #246

Open
dgillman opened this issue Feb 12, 2025 · 1 comment
Open

Persistent disk images not deleted #246

dgillman opened this issue Feb 12, 2025 · 1 comment
Labels

Comments

@dgillman
Copy link

dgillman commented Feb 12, 2025

Overview of the Issue

Root disks are not being cleaned up after image builds. I have found that the VMs which are created are cleaned up, but the root disks are not. I am using c3-highcpu-8 and am attaching 100GB pd-sdd disks. The auto-delete flag does not seem to be set, so builds are just littering the Google project with costly disks.

Reproduction Steps

I used this configuration:

source "googlecompute" "debian" {
  project_id            = var.project_id
  source_image          = var.source_image
  zone                  = var.zone
  machine_type          = var.machine_type
  subnetwork            = var.subnetwork
  service_account_email = "${var.service_account_email}@${var.project_id}.iam.gserviceaccount.com"
  instance_name         = "${var.image_name}-image-builder-{{timestamp}}"
  disk_type             = "pd-ssd"
  disk_size             = 100
  image_family          = var.image_prefix
  image_name            = "${var.image_name}-${var.version}"
  ssh_username          = var.username
}

If image_name is set to "foo", I end up with lingering persistent disks named like: foo-image-builder-1732137234

Plugin and Packer version

Packer: 1.12.0
googlecompute provider: 1.1.6

Simplified Packer Buildfile

build {
  sources = ["source.googlecompute.debian"]

  provisioner "shell" {
    inline = [
      "echo 'this is just an example. All provisioners are shell provisioners but I cannot share the details.",
    ]
  }
# ... the build contains 20+ shell provisioners
}

Operating system and Environment details

Debian 24.04 running in GitHub Actions

Log Fragments and crash.log files

Beginning of log

googlecompute.debian: output will be in this color.

==> googlecompute.debian: Checking image does not exist...
==> googlecompute.debian: Creating temporary RSA SSH key for instance...
==> googlecompute.debian: no persistent disk to create
==> googlecompute.debian: Using image: debian-11-bullseye-v20240611
==> googlecompute.debian: Creating instance...
    googlecompute.debian: Loading zone: us-east1-b
    googlecompute.debian: Loading machine type: c3-highcpu-8
    googlecompute.debian: Requesting instance creation...
    googlecompute.debian: Waiting for creation operation to complete...
    googlecompute.debian: Instance has been created!
==> googlecompute.debian: Waiting for the instance to become running...
    googlecompute.debian: IP: 34.23.128.19
==> googlecompute.debian: Using SSH communicator to connect: 34.23.128.19
==> googlecompute.debian: Waiting for SSH to become available...
==> googlecompute.debian: Connected to SSH!
==> googlecompute.debian: Provisioning with shell script: /tmp/packer-shell86024860

The provisioners all run without error. I cannot share details under NDA with my client. But the shells do simple things like configure logrotation, install custom Python software, and configure systemd services.

The logs end with this.

==> googlecompute.debian: Provisioning with shell script: /tmp/packer-shell3241388865
==> googlecompute.debian: Deleting instance...
    googlecompute.debian: Instance has been deleted!
==> googlecompute.debian: Creating image...
==> googlecompute.debian: Deleting disk...
    googlecompute.debian: Disk has been deleted!
Build 'googlecompute.debian' finished after 9 minutes 4 seconds.

At the end, I observe that the VM has been deleted, but the 100GB disk is still there.

@dgillman dgillman added the bug label Feb 12, 2025
@dgillman
Copy link
Author

I re-ran the same job with the PACKER_LOG environment variable set to 1. The log output did not provide any additional detail around VM and disk deletion:

==> googlecompute.debian: Deleting instance...
2025/02/12 17:06:52 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:06:52 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:06:55 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:06:55 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:06:57 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:06:57 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:06:59 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:06:59 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:02 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:02 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:04 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:04 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:07 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:07 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:09 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:09 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:12 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:12 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:14 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:14 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:16 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:16 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:19 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:19 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:21 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:21 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:23 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:23 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:26 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:26 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:28 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:28 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:30 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:30 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:33 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:33 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:35 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:35 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:38 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:38 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:40 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:40 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:43 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:43 Retryable error: retrying for state DONE, got RUNNING
    googlecompute.debian: Instance has been deleted!
==> googlecompute.debian: Creating image...
2025/02/12 17:07:47 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:47 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:49 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:49 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:51 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:51 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:53 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:53 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:56 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:56 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:07:58 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:07:58 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:00 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:00 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:02 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:02 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:05 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:05 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:07 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:07 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:09 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:09 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:11 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:11 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:14 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:14 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:16 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:16 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:18 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:18 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:20 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:20 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:23 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:23 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:25 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:25 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:27 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:27 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:29 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:29 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:31 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:31 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:34 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:34 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:36 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:36 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:38 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:38 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:41 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:41 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:43 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:43 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:46 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:46 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:48 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:48 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:50 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:50 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:52 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:52 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:55 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:55 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:57 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:57 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:08:59 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:08:59 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:01 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:01 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:04 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:04 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:06 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:06 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:08 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:08 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:10 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:10 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:13 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:13 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:15 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:15 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:17 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:17 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:19 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:19 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:22 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:22 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:24 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:24 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:26 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:26 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:28 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:28 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:31 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:31 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:33 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:33 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:35 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:35 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:37 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:37 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:40 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:40 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:42 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:42 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:44 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:44 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:46 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:46 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:49 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:49 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:51 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:51 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:53 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:53 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:55 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:55 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:09:57 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:09:57 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:00 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:00 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:02 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:02 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:04 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:04 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:06 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:06 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:09 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:09 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:11 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:11 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:13 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:13 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:15 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:15 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:18 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:18 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:20 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:20 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:22 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:22 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:24 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:24 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:27 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:27 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:29 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:29 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:31 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:31 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:33 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:33 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:36 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:36 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:38 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:38 Retryable error: retrying for state DONE, got RUNNING
2025/02/12 17:10:41 packer-plugin-googlecompute_v1.1.6_x5.0_linux_amd64 plugin: 2025/02/12 17:10:41 Retryable error: retrying for state DONE, got RUNNING
==> googlecompute.debian: Deleting disk...
    googlecompute.debian: Disk has been deleted!

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

1 participant