hashicorp / packer-plugin-googlecompute

Packer plugin for Google Compute Builder
https://www.packer.io/docs/builders/googlecompute
Mozilla Public License 2.0
24 stars 54 forks source link

Post-processor googlecompute-export fails with unexpected EOF #63

Closed hc-github-team-packer closed 2 years ago

hc-github-team-packer commented 2 years ago

This issue was originally opened by @diegolima in https://github.com/hashicorp/packer/issues/11419 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

Trying to use the googlecompute-export postprocessor causes the packer build to fail.

Reproduction Steps

Run packer build with the provided template.

Packer version

Packer v1.7.8

Simplified Packer Template

packer {
  required_plugins {
    googlecompute = {
      version = ">= 0.0.1"
      source = "github.com/hashicorp/googlecompute"
    }
  }
}

variable "root_password" {
  type = string
  default = "somepassword"
  sensitive = true
}
variable "gcp_bucket" {
  type = string
  default = "gs://my-bucket"
}

source "googlecompute" "centos79-cvp" {
  project_id = "cvp-tests"
  source_image = "centos-7-v20211105"
  ssh_username = "packer"
  zone = "us-central1-a"
}

build {
  name = "centos79-cvp"
  sources = ["sources.googlecompute.centos79-cvp"]
  provisioner "shell" {
    inline = [
      "yum list installed|grep @updates|awk '{print $1}'|xargs sudo yum -y downgrade --disablerepo=updates",
      "sudo sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config",
      "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config",
      "echo -e \"${var.root_password}\n${var.root_password}\"|sudo passwd root"
    ]
  }
  post-processor "googlecompute-export" {
    paths = [
      "${var.gcp_bucket}/centos79-cvp-autobuild.tar.gz"
    ]
  }
}

Operating system and Environment details

I'm running packer under Ubuntu 20.04.3 on Windows 10 WSL:

  NAME                   STATE           VERSION
* Ubuntu                 Running         2

Log Fragments and crash.log files

When running with PACKER_LOG=1 I could see the following while running the post-processor:

==> centos79-cvp.googlecompute.centos79-cvp: Running post-processor:  (type googlecompute-export)
==> centos79-cvp.googlecompute.centos79-cvp (googlecompute-export): Exporting image packer-1638182956 to destination: [gs://my-bucket/centos79-cvp-autobuild.tar.gz]
2021/11/29 11:52:56 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: 2021/11/29 11:52:56 [INFO] Requesting Google token via GCE API Default Client Token Source...
2021/11/29 11:52:56 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: 2021/11/29 11:52:56 [INFO] Instantiating GCE client...
2021/11/29 11:52:56 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: 2021/11/29 11:52:56 [INFO] Instantiating OS Login client...
==> centos79-cvp.googlecompute.centos79-cvp (googlecompute-export): Creating temporary RSA SSH key for instance...
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: panic: runtime error: invalid memory address or nil pointer dereference
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6383e5]
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: 
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: goroutine 82 [running]:
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/packerbuilderdata.(*GeneratedData).Put(0x0, {0x1380274, 0xf}, {0x10bce80, 0xc0002f3c90})
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         github.com/hashicorp/packer-plugin-sdk@v0.2.7/packerbuilderdata/generated_data.go:26 +0x45
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-googlecompute/builder/googlecompute.(*StepCreateInstance).Run(0xc000480820, {0x15d7848, 0xc000122740}, {0x15d7ce0, 0xc000303740})
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         github.com/hashicorp/packer-plugin-googlecompute/builder/googlecompute/step_create_instance.go:130 +0x259
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*BasicRunner).Run(0xc0003037a0, {0x15d7848, 0xc000122740}, {0x15d7ce0, 0xc000303740})
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         github.com/hashicorp/packer-plugin-sdk@v0.2.7/multistep/basic_runner.go:70 +0x2fe
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-googlecompute/post-processor/googlecompute-export.(*PostProcessor).PostProcess(0xc00000a1e0, {0x15d7848, 0xc000122740}, {0x15de978, 0xc0007a2e70}, {0x15de9c0, 0xc000308960})
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         github.com/hashicorp/packer-plugin-googlecompute/post-processor/googlecompute-export/post-processor.go:238 +0xdd9
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*PostProcessorServer).PostProcess(0xc000122000, 0x7b68b8, 0xc000480100)
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         github.com/hashicorp/packer-plugin-sdk@v0.2.7/rpc/post_processor.go:108 +0x18c
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: reflect.Value.call({0xc00056e360, 0xc000306080, 0x13}, {0x1373c9f, 0x4}, {0xc0005ddef8, 0x3, 0x3})
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         reflect/value.go:543 +0x814
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: reflect.Value.Call({0xc00056e360, 0xc000306080, 0xc00060a000}, {0xc0003776f8, 0x3, 0x3})
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         reflect/value.go:339 +0xc5
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: net/rpc.(*service).call(0xc000122040, 0xc00011c0b5, 0x0, 0xc000732100, 0xc000752280, 0x60be05, {0x10bd080, 0xc0007b68a8, 0x60bd86}, {0x106c960, ...}, ...)
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         net/rpc/server.go:377 +0x239
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: created by net/rpc.(*Server).ServeCodec
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin:         net/rpc/server.go:474 +0x405
2021/11/29 11:53:25 [INFO] (telemetry) ending googlecompute-export
2021/11/29 11:53:25 Deleting original artifact for build 'googlecompute.centos79-cvp'
2021/11/29 11:53:25 /root/.config/packer/plugins/github.com/hashicorp/googlecompute/packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64: plugin process exited
2021/11/29 11:53:25 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: 2021/11/29 11:53:25 Destroying image: packer-1638182956
2021/11/29 11:53:27 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: 2021/11/29 11:53:27 Retryable error: retrying for state DONE, got RUNNING
2021/11/29 11:53:29 packer-plugin-googlecompute_v1.0.6_x5.0_linux_amd64 plugin: 2021/11/29 11:53:29 Retryable error: retrying for state DONE, got RUNNING

Build 'centos79-cvp.googlecompute.centos79-cvp' errored after 4 minutes 15 seconds: 1 error(s) occurred:
* Post-processor failed: unexpected EOF