no panicwrap in plugins
As of mitchellh/panicwrap#25, a call to panicwrap.Wrapped() unsets the cookie in the env, that makes packer plugin child process inherit an env without the panicwrap cookie and panicwrap itself. This trips up CleanupClients() in Packer's plugin client: instead of the real plugin server it now kills its panicwrap parent -- which doesn't forward SIGKILL to its child because it's not a signal that can be caught -- and ends up indefinitely waiting in client.Kill() for an EOF that will never come. This workaround is to not even try to panicwrap in a plugin server.
This commit is contained in:
parent
984f21d409
commit
d18b7839b9
16
main.go
16
main.go
|
@ -43,7 +43,11 @@ func realMain() int {
|
|||
wrapConfig.CookieKey = "PACKER_WRAP_COOKIE"
|
||||
wrapConfig.CookieValue = "49C22B1A-3A93-4C98-97FA-E07D18C787B5"
|
||||
|
||||
if !panicwrap.Wrapped(&wrapConfig) {
|
||||
if inPlugin() || panicwrap.Wrapped(&wrapConfig) {
|
||||
// Call the real main
|
||||
return wrappedMain()
|
||||
}
|
||||
|
||||
// Generate a UUID for this packer run and pass it to the environment.
|
||||
// GenerateUUID always returns a nil error (based on rand.Read) so we'll
|
||||
// just ignore it.
|
||||
|
@ -118,10 +122,8 @@ func realMain() int {
|
|||
// We're the child, so just close the tempfile we made in order to
|
||||
// save file handles since the tempfile is only used by the parent.
|
||||
logTempFile.Close()
|
||||
}
|
||||
|
||||
// Call the real main
|
||||
return wrappedMain()
|
||||
return 0
|
||||
}
|
||||
|
||||
// wrappedMain is called only when we're wrapped by panicwrap and
|
||||
|
@ -135,7 +137,7 @@ func wrappedMain() int {
|
|||
packer.LogSecretFilter.SetOutput(os.Stderr)
|
||||
log.SetOutput(&packer.LogSecretFilter)
|
||||
|
||||
inPlugin := os.Getenv(plugin.MagicCookieKey) == plugin.MagicCookieValue
|
||||
inPlugin := inPlugin()
|
||||
if inPlugin {
|
||||
// This prevents double-logging timestamps
|
||||
log.SetFlags(0)
|
||||
|
@ -387,6 +389,10 @@ func copyOutput(r io.Reader, doneCh chan<- struct{}) {
|
|||
wg.Wait()
|
||||
}
|
||||
|
||||
func inPlugin() bool {
|
||||
return os.Getenv(plugin.MagicCookieKey) == plugin.MagicCookieValue
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Seed the random number generator
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
|
Loading…
Reference in New Issue