Skip to content

Commit

Permalink
fix: error early when the image write fails (#34)
Browse files Browse the repository at this point in the history
Closes #33
  • Loading branch information
apricote authored Jun 23, 2024
1 parent 8347e4e commit 256989f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hcloudimages/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ func (s *Client) Upload(ctx context.Context, options UploadOptions) (*hcloud.Ima
}

cmd += "dd of=/dev/sda bs=4M && sync"

// Make sure that we fail early, ie. if the image url does not work.
// the pipefail does not work correctly without wrapping in bash.
cmd = fmt.Sprintf("bash -c 'set -euo pipefail && %s'", cmd)
logger.DebugContext(ctx, "running download, decompress and write to disk command", "cmd", cmd)

output, err := sshsession.Run(sshClient, cmd, options.ImageReader)
Expand Down

0 comments on commit 256989f

Please sign in to comment.