hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.06k stars 3.32k forks source link

Packer freezes with SIGTTOU when run as bash background job (1.4.0 and later) #7677

Closed ThisGuyCodes closed 5 years ago

ThisGuyCodes commented 5 years ago

Run literally any packer command as a bash job, without providing the -machine-readable flag. No need to provide a file, or actually even a command:

# packer &                                                                                                                     
[2] 13025
[2]  + 13025 suspended (tty output)  packer                                                                                                          
#

Using the -machine-readable flag fixes the issue; but I don't have a system to process that output, it's much more useful to me to have the original output. This issue is only encountered with packer 1.4.0 or later.

I use please.build as my build system: and this broke my builds when trying to upgrade packer. I'm not certain if please is using bash job control specifically, but SIGTTOU is still what's locking things up.

debug output for completeness:

2019/05/22 11:05:40 [INFO] Packer version: 1.4.1                                                                                                     
2019/05/22 11:05:40 Packer Target OS/Arch: linux amd64
2019/05/22 11:05:40 Built with Go Version: go1.12.5
2019/05/22 11:05:40 Detected home directory from env var: /home/thisguy
2019/05/22 11:05:40 Using internal plugin for digitalocean
2019/05/22 11:05:40 Using internal plugin for scaleway
2019/05/22 11:05:40 Using internal plugin for amazon-ebsvolume
2019/05/22 11:05:40 Using internal plugin for azure-arm
2019/05/22 11:05:40 Using internal plugin for parallels-iso
2019/05/22 11:05:40 Using internal plugin for proxmox
2019/05/22 11:05:40 Using internal plugin for qemu
2019/05/22 11:05:40 Using internal plugin for triton
2019/05/22 11:05:40 Using internal plugin for vagrant
2019/05/22 11:05:40 Using internal plugin for yandex
2019/05/22 11:05:40 Using internal plugin for amazon-ebs
2019/05/22 11:05:40 Using internal plugin for hyperv-vmcx
2019/05/22 11:05:40 Using internal plugin for oracle-classic
2019/05/22 11:05:40 Using internal plugin for oracle-oci
2019/05/22 11:05:40 Using internal plugin for parallels-pvm
2019/05/22 11:05:40 Using internal plugin for linode
2019/05/22 11:05:40 Using internal plugin for ncloud
2019/05/22 11:05:40 Using internal plugin for hyperv-iso
2019/05/22 11:05:40 Using internal plugin for lxd
2019/05/22 11:05:40 Using internal plugin for vmware-iso
2019/05/22 11:05:40 Using internal plugin for googlecompute
2019/05/22 11:05:40 Using internal plugin for hyperone
2019/05/22 11:05:40 Using internal plugin for docker
2019/05/22 11:05:40 Using internal plugin for lxc
2019/05/22 11:05:40 Using internal plugin for null
2019/05/22 11:05:40 Using internal plugin for profitbricks
2019/05/22 11:05:40 Using internal plugin for virtualbox-ovf
2019/05/22 11:05:40 Using internal plugin for vmware-vmx
2019/05/22 11:05:40 Using internal plugin for alicloud-ecs
2019/05/22 11:05:40 Using internal plugin for amazon-ebssurrogate
2019/05/22 11:05:40 Using internal plugin for openstack
2019/05/22 11:05:40 Using internal plugin for tencentcloud-cvm
2019/05/22 11:05:40 Using internal plugin for amazon-instance
2019/05/22 11:05:40 Using internal plugin for hcloud
2019/05/22 11:05:40 Using internal plugin for file
2019/05/22 11:05:40 Using internal plugin for oneandone
2019/05/22 11:05:40 Using internal plugin for virtualbox-iso
2019/05/22 11:05:40 Using internal plugin for amazon-chroot
2019/05/22 11:05:40 Using internal plugin for cloudstack
2019/05/22 11:05:40 Using internal plugin for puppet-server
2019/05/22 11:05:40 Using internal plugin for salt-masterless
2019/05/22 11:05:40 Using internal plugin for shell-local
2019/05/22 11:05:40 Using internal plugin for windows-shell
2019/05/22 11:05:40 Using internal plugin for ansible
2019/05/22 11:05:40 Using internal plugin for converge
2019/05/22 11:05:40 Using internal plugin for file
2019/05/22 11:05:40 Using internal plugin for sleep
2019/05/22 11:05:40 Using internal plugin for windows-restart
2019/05/22 11:05:40 Using internal plugin for breakpoint
2019/05/22 11:05:40 Using internal plugin for chef-solo
2019/05/22 11:05:40 Using internal plugin for puppet-masterless
2019/05/22 11:05:40 Using internal plugin for powershell
2019/05/22 11:05:40 Using internal plugin for shell
2019/05/22 11:05:40 Using internal plugin for ansible-local
2019/05/22 11:05:40 Using internal plugin for chef-client
2019/05/22 11:05:40 Using internal plugin for inspec
2019/05/22 11:05:40 Using internal plugin for vagrant
2019/05/22 11:05:40 Using internal plugin for vsphere-template
2019/05/22 11:05:40 Using internal plugin for alicloud-import
2019/05/22 11:05:40 Using internal plugin for digitalocean-import
2019/05/22 11:05:40 Using internal plugin for docker-tag
2019/05/22 11:05:40 Using internal plugin for manifest
2019/05/22 11:05:40 Using internal plugin for shell-local
2019/05/22 11:05:40 Using internal plugin for vsphere
2019/05/22 11:05:40 Using internal plugin for amazon-import
2019/05/22 11:05:40 Using internal plugin for compress
2019/05/22 11:05:40 Using internal plugin for docker-import
2019/05/22 11:05:40 Using internal plugin for docker-push
azr commented 5 years ago

This looks related to https://github.com/hashicorp/packer/issues/7592

ThisGuyCodes commented 5 years ago

Yea, looks like the exact same issue.

I think this has to do with this 1.4.0 feature mentioned in the blog post:

Packer now uses a tty to receive user inputs.

This signal occurs when a process tries to set the TTY while it's not "foreground". I'm not entirely sure what they mean by "uses a TTY" though.

ThisGuyCodes commented 5 years ago

Issue I opened on go-tty: https://github.com/mattn/go-tty/issues/26

My thought is that go-tty could return an error if it would suspend the process. I'm not 100% on that making sense though.

Alternatively I found a very lightweight package that can report on whether you are in the foreground process group: https://github.com/snabb/tcxpgrp (lightweight enough that a copy-paste may make more sense), this could be used to disable use of a TTY when in the background (it's not relevant without a user present anyway I think).

What I don't think of as an option is leaving the current behavior. Packer used to work in build situations where it no longer does.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.