track whether we've detached disks so we don't duplicate work

pull/9932/head
Megan Marsh 6 years ago
parent a92491d17b
commit 698bef434f

@ -145,14 +145,14 @@ func (s *StepAttachISOs) Cleanup(state multistep.StateBag) {
}
driver := state.Get("driver").(Driver)
_, ok := state.GetOk("detached_isos")
for _, command := range s.diskUnmountCommands {
// Remove the ISO. Note that this will probably fail since
// stepRemoveDevices does this as well. No big deal.
err := driver.VBoxManage(command...)
if err != nil {
log.Printf("error detaching iso; probably was already detached " +
"in step_remove_devices")
if !ok {
for _, command := range s.diskUnmountCommands {
err := driver.VBoxManage(command...)
if err != nil {
log.Printf("error detaching iso: %s", err)
}
}
}
}

@ -95,6 +95,10 @@ func (s *StepRemoveDevices) Run(ctx context.Context, state multistep.StateBag) m
}
}
// log that we removed the isos, so we don't waste time trying to do it
// in the step_attach_isos cleanup.
state.Put("detached_isos", true)
return multistep.ActionContinue
}

Loading…
Cancel
Save