Skip to content

Commit fe8eafe

Browse files
committed
restart the pending restart session when interrupted
1 parent 929b359 commit fe8eafe

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Configure your packer template to require a [release version of the plugin](http
1414
packer {
1515
required_plugins {
1616
windows-update = {
17-
version = "0.17.0"
17+
version = "0.17.1"
1818
source = "github.com/rgl/windows-update"
1919
}
2020
}

update/provisioner.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,23 @@ func (p *Provisioner) restart(ctx context.Context, ui packer.Ui, comm packer.Com
273273

274274
ui.Say("Checking for pending restart...")
275275
err = p.retryable(ctx, func(ctx context.Context) error {
276+
ui := NewUpdateUi(ui)
276277
cmd := &packer.RemoteCmd{Command: pendingRebootElevatedCommand}
277278
err = cmd.RunWithUi(ctx, comm, ui)
278279
if err != nil {
279280
return err
280281
}
282+
if !ui.finished {
283+
return fmt.Errorf("Windows update script did not finish")
284+
}
281285

282286
exitStatus := cmd.ExitStatus()
283-
switch {
284-
case exitStatus == 0:
287+
switch exitStatus {
288+
case 0:
285289
restartPending = false
286-
case exitStatus == 101:
290+
case 101:
287291
restartPending = true
288-
case exitStatus == 2147942501: //windows 2012
292+
case 2147942501: //windows 2012
289293
restartPending = true
290294
default:
291295
return fmt.Errorf("Machine not yet available (exit status %d)", exitStatus)

0 commit comments

Comments
 (0)