Closed natedogith1 closed 2 years ago
Hi @natedogith1 thanks for reaching out. The behavior you are describing is exactly how abort is meant to work. In a normal build flow (either failure or success) there is a cleanup step that is responsible for tearing down any sub processes started during a build - including the termination of an IAP tunnel.
However since Packer is being told to abort on error, Packer will exit immediately and not run any cleanup steps. Hence why the IAP tunnel and any other resources created during the build are not terminated.
Is there a reason why you chose --on-error=abort
over --on-error=ask
?
If you wish to investigate a failed provisioner you could instead pass --on-error=ask
to the build command. Upon failure Packer will prompt you for instructions on how to continue. During this time you could connect to the running instance to troubleshoot. Then when ready you can retry, abort, or just cleanup to exit properly.
This is being run on a CI/CD pipeline and --on-error=ask require interaction.
Hi @natedogith1 thanks for that extra info. At this time I have no work around other than using an external script to find the PID associated with the tunnel and terminating it from within the script. By hard aborting Packer all cleanup processes are skipped.
At this time the IAP does not seem to offer the ability to set a no-activity timeout that would automatically terminate the tunnel. According to the Google documentation the tunnel will terminate itself after 1 hour.
I'm going to close this issue as there is no solution for cleaning up once a build is aborted. But I'll apply the track-internal label so that we can revisit the Google SDK/CLI in the future if things should change.
I have multiple IAP tunnel processes that have been running for days without a connection and with the VM deleted.
Overview of the Issue
When -on-error=abort is used with packer build (so that the VM can be inspected if something fails) and a provisioning error occurs, the IAP tunnel process never stops.
Reproduction Steps
Plugin and Packer version
Packer v1.7.5
Operating system and Environment details
Running from gitlab on a Centos 8 gitlab runner.
Log Fragments and crash.log files
Followed by a wait until the pipeline is timed out or someone logs in and manually kills the tunnel process.