Skip to content

Commit

Permalink
sgdisk: retry zap-all operation on failure
Browse files Browse the repository at this point in the history
sgdisk is a bit weird and will exit with code 2 if there is trouble with the GPT
headers, even it successfully zaps them. Retrying the zap operation will allow
us to be sure that the operation completed successfully.
  • Loading branch information
crawford committed Jan 12, 2016
1 parent 6159283 commit 94c98bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sgdisk/sgdisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ func (op *Operation) Commit() error {
if op.wipe {
cmd := exec.Command(sgdiskPath, "--zap-all", op.dev)
if err := op.logger.LogCmd(cmd, "wiping table on %q", op.dev); err != nil {
return fmt.Errorf("wipe failed: %v")
op.logger.Info("potential error encountered while wiping table... retrying")
cmd = exec.Command(sgdiskPath, "--zap-all", op.dev)
if err := op.logger.LogCmd(cmd, "wiping table on %q", op.dev); err != nil {
return fmt.Errorf("wipe failed: %v")
}
}
}

Expand Down

0 comments on commit 94c98bc

Please sign in to comment.