upload volume WIP
check upload for error increase builder volume size to account for chunking
This commit is contained in:
parent
8598e2d0a3
commit
96e62236ec
|
@ -79,7 +79,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
bootable: true,
|
bootable: true,
|
||||||
},
|
},
|
||||||
&stepCreatePersistentVolume{
|
&stepCreatePersistentVolume{
|
||||||
volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize*2),
|
// We multiple the master volume size by 3, because we need to
|
||||||
|
// copy the original data 3 times: the data itself, the
|
||||||
|
// tarball, and the chunks
|
||||||
|
volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize*3),
|
||||||
volumeName: fmt.Sprintf("builder-storage_%s", runID),
|
volumeName: fmt.Sprintf("builder-storage_%s", runID),
|
||||||
},
|
},
|
||||||
&ocommon.StepKeyPair{
|
&ocommon.StepKeyPair{
|
||||||
|
|
|
@ -28,7 +28,30 @@ func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.BuilderUploadImageCommand == "" {
|
if c.BuilderUploadImageCommand == "" {
|
||||||
c.BuilderUploadImageCommand = `curl --connect-timeout 5 \
|
c.BuilderUploadImageCommand = `split -b 10m diskimage.tar.gz segment_
|
||||||
|
|
||||||
|
curl -D auth-headers -s -X GET -H "X-Storage-User: Storage-a459477:jake@hashicorp.com" -H "X-Storage-Pass: ***REMOVED***" https://a459477.storage.oraclecloud.com/auth/v1.0
|
||||||
|
|
||||||
|
export AUTH_TOKEN=$(awk 'BEGIN {FS=": "; RS="\r\n"}/^X-Auth-Token/{print $2}' auth-headers)
|
||||||
|
export STORAGE_URL=$(awk 'BEGIN {FS=": "; RS="\r\n"}/^X-Storage-Url/{print $2}' auth-headers)
|
||||||
|
|
||||||
|
curl -v -X PUT -H "X-Auth-Token: $AUTH_TOKEN" ${STORAGE_URL}/mwhooker-test-1
|
||||||
|
|
||||||
|
for i in segment_*; do
|
||||||
|
curl -v -X PUT -T $i \
|
||||||
|
-H "X-Auth-Token: $AUTH_TOKEN" \
|
||||||
|
${STORAGE_URL}/mwhooker-test-1/$i;
|
||||||
|
done
|
||||||
|
|
||||||
|
(
|
||||||
|
echo [
|
||||||
|
for i in segment_*; do
|
||||||
|
printf '{"path": "%s", "etag": "%s", "size_bytes": %s},\n' "mwhooker-test-1/$i" $(md5sum $i | cut -f1 -d' ') $(stat --printf "%s" $i)
|
||||||
|
done
|
||||||
|
echo ]
|
||||||
|
) > manifest.json
|
||||||
|
|
||||||
|
curl --connect-timeout 5 \
|
||||||
--max-time 3600 \
|
--max-time 3600 \
|
||||||
--retry 5 \
|
--retry 5 \
|
||||||
--retry-delay 0 \
|
--retry-delay 0 \
|
||||||
|
|
|
@ -52,7 +52,14 @@ func (s *stepCreateImage) Run(_ context.Context, state multistep.StateBag) multi
|
||||||
Command: fmt.Sprintf("sudo /bin/sh %s", dest),
|
Command: fmt.Sprintf("sudo /bin/sh %s", dest),
|
||||||
}
|
}
|
||||||
if err := cmd.StartWithUi(comm, ui); err != nil {
|
if err := cmd.StartWithUi(comm, ui); err != nil {
|
||||||
err = fmt.Errorf("Problem creating volume: %s", err)
|
err = fmt.Errorf("Problem creating image`: %s", err)
|
||||||
|
ui.Error(err.Error())
|
||||||
|
state.Put("error", err)
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.ExitStatus != 0 {
|
||||||
|
err = fmt.Errorf("Create Disk Image command failed with exit code %d", cmd.ExitStatus)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
|
|
Loading…
Reference in New Issue