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
46f518f2
Commit
46f518f2
authored
Jun 12, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/openstack: proper error extraction
parent
7a46b80c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
16 deletions
+13
-16
builder/openstack-new/server.go
builder/openstack-new/server.go
+5
-10
builder/openstack-new/step_create_image.go
builder/openstack-new/step_create_image.go
+8
-6
No files found.
builder/openstack-new/server.go
View file @
46f518f2
...
...
@@ -36,20 +36,15 @@ type StateChangeConf struct {
func
ServerStateRefreshFunc
(
client
*
gophercloud
.
ServiceClient
,
s
*
servers
.
Server
)
StateRefreshFunc
{
return
func
()
(
interface
{},
string
,
int
,
error
)
{
var
serverNew
*
servers
.
Server
result
:=
servers
.
Get
(
client
,
s
.
ID
)
err
:=
result
.
Err
if
err
==
nil
{
serverNew
,
err
=
result
.
Extract
()
}
if
result
.
Err
!=
nil
{
errCode
,
ok
:=
result
.
Err
.
(
*
gophercloud
.
UnexpectedResponseCodeError
)
serverNew
,
err
:=
servers
.
Get
(
client
,
s
.
ID
)
.
Extract
()
if
err
!=
nil
{
errCode
,
ok
:=
err
.
(
*
gophercloud
.
UnexpectedResponseCodeError
)
if
ok
&&
errCode
.
Actual
==
404
{
log
.
Printf
(
"[INFO] 404 on ServerStateRefresh, returning DELETED"
)
return
nil
,
"DELETED"
,
0
,
nil
}
else
{
log
.
Printf
(
"[ERROR] Error on ServerStateRefresh: %s"
,
result
.
E
rr
)
return
nil
,
""
,
0
,
result
.
E
rr
log
.
Printf
(
"[ERROR] Error on ServerStateRefresh: %s"
,
e
rr
)
return
nil
,
""
,
0
,
e
rr
}
}
...
...
builder/openstack-new/step_create_image.go
View file @
46f518f2
...
...
@@ -62,13 +62,15 @@ func (s *stepCreateImage) Cleanup(multistep.StateBag) {
// WaitForImage waits for the given Image ID to become ready.
func
WaitForImage
(
client
*
gophercloud
.
ServiceClient
,
imageId
string
)
error
{
for
{
var
image
*
images
.
Image
result
:=
images
.
Get
(
client
,
imageId
)
err
:=
result
.
Err
if
err
==
nil
{
image
,
err
=
result
.
Extract
()
}
image
,
err
:=
images
.
Get
(
client
,
imageId
)
.
Extract
()
if
err
!=
nil
{
errCode
,
ok
:=
err
.
(
*
gophercloud
.
UnexpectedResponseCodeError
)
if
ok
&&
errCode
.
Actual
==
500
{
log
.
Printf
(
"[ERROR] 500 error received, will ignore and retry: %s"
,
err
)
time
.
Sleep
(
2
*
time
.
Second
)
continue
}
return
err
}
...
...
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