Cleanup VM in case of a failure - #120
Conversation
|
@sparshev FYI |
|
Sorry, see just one file is changed, but according to the builder you have 3 separated steps for this matter:
But I'm not sure I really understand the codebase, so could be wrong. |
|
Good catch, @sparshev! I've extracted cleanup in a separate step which is the first one. |
|
Yep, now looks better!) Do you think this PR will contain a fix for Ctrl-C issue as well, because in description it says |
|
It seems it will be handled according to Packer documentation:
|
|
I'm talking about a bit different behavior: the issue with Ctrl-C that Tart VM is going down immediately after Ctrl-C, not after cleanup operation... So when you press Ctrl-C in packer with |
|
Oh. I think I misunderstood you but I still think that @edigaryev is on PTO so I'm going to merge now so we can do a release. He'll review the change post-factum. |
|
Does this take the
If I pass It seems to work fine if the cancellation is coming from a step, e.g. if the SSH times out. In that case the cleanup is not run when I choose so via the |
|
"Internal" failure. Choice respected: Ctrl+C. Choice ignored: |
This seems to be done intentionally by the Packer: func ask(ui packersdk.Ui, name string, state multistep.StateBag) askResponse {
ui.Say(fmt.Sprintf("Step %q failed", name))
result := make(chan askResponse)
go func() {
result <- askPrompt(ui)
}()
for {
select {
case response := <-result:
return response
case <-time.After(100 * time.Millisecond):
if _, ok := state.GetOk(multistep.StateCancelled); ok {
return askCleanup
}
}
}
}I've created a hashicorp/packer-plugin-sdk#226 to address this. |
|
Awesome @edigaryev ! |
Fixes #115