investigate packer segfaulting while copying images to aws regions
During 11.1.0 release we've been seeing issues with packer failing to complete it's copy of the ami to other regions.
Packer also doesn't make the images public until after the copy, so when the copy fails we've effectively not released the ami.
Example of failure:
panic: runtime error: invalid memory address or nil pointer dereference
2018/07/22 14:47:39 packer: [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x90860f]
2018/07/22 14:47:39 packer:
2018/07/22 14:47:39 packer: goroutine 7812 [running]:
2018/07/22 14:47:39 packer: panic(0x1432d80, 0xc4200160d0)
2018/07/22 14:47:39 packer: /usr/local/Cellar/go/1.7.4/libexec/src/runtime/panic.go:500 +0x1a1
2018/07/22 14:47:39 packer: github.com/mitchellh/packer/builder/amazon/common.amiRegionCopy(0x1ece800, 0xc4203dac90, 0xc42029af40, 0xc4203758d0, 0x10, 0xc42012da00, 0xc, 0xc4203750d0, 0x9, 0xc420375740, ...)
2018/07/22 14:47:39 packer: /Users/mwhooker/go/src/github.com/mitchellh/packer/builder/amazon/common/step_ami_region_copy.go:132 +0x55f
2018/07/22 14:47:39 packer: github.com/mitchellh/packer/builder/amazon/common.(*StepAMIRegionCopy).Run.func1(0xc42022b1d0, 0x1ece800, 0xc4203dac90, 0xc4203dad50, 0xc42012da00, 0xc, 0xc420052388, 0xc42022b1b8, 0xc4201335c0, 0xc42056b440, ...)
2018/07/22 14:47:39 packer: /Users/mwhooker/go/src/github.com/mitchellh/packer/builder/amazon/common/step_ami_region_copy.go:50 +0x103
2018/07/22 14:47:39 packer: created by github.com/mitchellh/packer/builder/amazon/common.(*StepAMIRegionCopy).Run
2018/07/22 14:47:39 packer: /Users/mwhooker/go/src/github.com/mitchellh/packer/builder/amazon/common/step_ami_region_copy.go:59 +0x5c8
2018/07/22 14:47:39 ui error: Build 'amazon-ebs' errored: unexpected EOF
2018/07/22 14:47:39 Builds completed. Waiting on interrupt barrier...
2018/07/22 14:47:39 /usr/local/bin/packer: plugin process exited
2018/07/22 14:47:39 machine readable: error-count []string{"1"}
2018/07/22 14:47:39 ui error:
==> Some builds didn't complete successfully and had errors:
2018/07/22 14:47:39 machine readable: amazon-ebs,error []string{"unexpected EOF"}
2018/07/22 14:47:39 ui error: --> amazon-ebs: unexpected EOF
2018/07/22 14:47:39 ui:
==> Builds finished but no artifacts were created.
2018/07/22 14:47:39 waiting for all plugin processes to complete...
2018/07/22 14:47:39 /usr/local/bin/packer: plugin process exited
!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
Packer crashed! This is always indicative of a bug within Packer.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Packer[1] so that we can fix this.
[1]: https://github.com/mitchellh/packer/issues
!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
As a workaround for now, when it happens we've gone in to the aws console, removed the old ami, and retried the job.