Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
f6660e8a
Commit
f6660e8a
authored
Jun 18, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/vagrant-cloud: retry uploads [GH-2167]
parent
d9fceaf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
+31
-4
post-processor/vagrant-cloud/step_upload.go
post-processor/vagrant-cloud/step_upload.go
+31
-4
No files found.
post-processor/vagrant-cloud/step_upload.go
View file @
f6660e8a
...
...
@@ -2,6 +2,8 @@ package vagrantcloud
import
(
"fmt"
"time"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
)
...
...
@@ -17,13 +19,38 @@ func (s *stepUpload) Run(state multistep.StateBag) multistep.StepAction {
url
:=
upload
.
UploadPath
ui
.
Say
(
fmt
.
Sprintf
(
"Uploading box: %s"
,
artifactFilePath
))
ui
.
Message
(
"Depending on your internet connection and the size of the box,
\n
"
+
"this may take some time"
)
var
finalErr
error
for
i
:=
0
;
i
<
3
;
i
++
{
if
i
>
0
{
ui
.
Message
(
fmt
.
Sprintf
(
"Uploading box, attempt %d"
,
i
+
1
))
}
ui
.
Message
(
"Depending on your internet connection and the size of the box, this may take some time"
)
resp
,
err
:=
client
.
Upload
(
artifactFilePath
,
url
)
if
err
!=
nil
{
finalErr
=
err
ui
.
Message
(
fmt
.
Sprintf
(
"Error uploading box! Will retry in 10 seconds. Error: %s"
,
err
))
time
.
Sleep
(
10
*
time
.
Second
)
continue
}
if
resp
.
StatusCode
!=
200
{
finalErr
=
fmt
.
Errorf
(
"bad HTTP status: %d"
,
resp
.
StatusCode
)
ui
.
Message
(
fmt
.
Sprintf
(
"Error uploading box! Will retry in 10 seconds. Status: %d"
,
resp
.
StatusCode
))
time
.
Sleep
(
10
*
time
.
Second
)
continue
}
resp
,
err
:=
client
.
Upload
(
artifactFilePath
,
url
)
finalErr
=
nil
}
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
state
.
Put
(
"error"
,
f
mt
.
Errorf
(
"Error uploading Box: %s"
,
err
)
)
if
finalErr
!=
nil
{
state
.
Put
(
"error"
,
f
inalErr
)
return
multistep
.
ActionHalt
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment