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
296f8286
Commit
296f8286
authored
Jun 10, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'renat-sabitov-fix_amazon_instance_waits'
parents
7410289c
8e1db0d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
26 deletions
+7
-26
builder/amazon/common/state.go
builder/amazon/common/state.go
+2
-2
builder/amazon/common/step_run_source_instance.go
builder/amazon/common/step_run_source_instance.go
+4
-23
builder/amazon/ebs/step_stop_instance.go
builder/amazon/ebs/step_stop_instance.go
+1
-1
No files found.
builder/amazon/common/state.go
View file @
296f8286
...
...
@@ -67,10 +67,10 @@ func AMIStateRefreshFunc(conn *ec2.EC2, imageId string) StateRefreshFunc {
// InstanceStateRefreshFunc returns a StateRefreshFunc that is used to watch
// an EC2 instance.
func
InstanceStateRefreshFunc
(
conn
*
ec2
.
EC2
,
i
*
ec2
.
Instance
)
StateRefreshFunc
{
func
InstanceStateRefreshFunc
(
conn
*
ec2
.
EC2
,
i
nstanceId
string
)
StateRefreshFunc
{
return
func
()
(
interface
{},
string
,
error
)
{
resp
,
err
:=
conn
.
DescribeInstances
(
&
ec2
.
DescribeInstancesInput
{
InstanceIDs
:
[]
*
string
{
i
.
InstanceID
},
InstanceIDs
:
[]
*
string
{
&
instanceId
},
})
if
err
!=
nil
{
if
ec2err
,
ok
:=
err
.
(
awserr
.
Error
);
ok
&&
ec2err
.
Code
()
==
"InvalidInstanceID.NotFound"
{
...
...
builder/amazon/common/step_run_source_instance.go
View file @
296f8286
...
...
@@ -223,31 +223,12 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
instanceId
=
*
spotResp
.
SpotInstanceRequests
[
0
]
.
InstanceID
}
instanceResp
,
err
:=
ec2conn
.
DescribeInstances
(
&
ec2
.
DescribeInstancesInput
{
InstanceIDs
:
[]
*
string
{
&
instanceId
}})
for
i
:=
0
;
i
<
10
;
i
++
{
if
err
==
nil
{
break
}
time
.
Sleep
(
3
*
time
.
Second
)
instanceResp
,
err
=
ec2conn
.
DescribeInstances
(
&
ec2
.
DescribeInstancesInput
{
InstanceIDs
:
[]
*
string
{
&
instanceId
}})
}
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error finding source instance (%s): %s"
,
instanceId
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
s
.
instance
=
instanceResp
.
Reservations
[
0
]
.
Instances
[
0
]
ui
.
Message
(
fmt
.
Sprintf
(
"Instance ID: %s"
,
*
s
.
instance
.
InstanceID
))
ui
.
Say
(
fmt
.
Sprintf
(
"Waiting for instance (%s) to become ready..."
,
*
s
.
instance
.
InstanceID
))
ui
.
Message
(
fmt
.
Sprintf
(
"Instance ID: %s"
,
instanceId
))
ui
.
Say
(
fmt
.
Sprintf
(
"Waiting for instance (%v) to become ready..."
,
instanceId
))
stateChange
:=
StateChangeConf
{
Pending
:
[]
string
{
"pending"
},
Target
:
"running"
,
Refresh
:
InstanceStateRefreshFunc
(
ec2conn
,
s
.
instance
),
Refresh
:
InstanceStateRefreshFunc
(
ec2conn
,
instanceId
),
StepState
:
state
,
}
latestInstance
,
err
:=
WaitForState
(
&
stateChange
)
...
...
@@ -329,7 +310,7 @@ func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag) {
}
stateChange
:=
StateChangeConf
{
Pending
:
[]
string
{
"pending"
,
"running"
,
"shutting-down"
,
"stopped"
,
"stopping"
},
Refresh
:
InstanceStateRefreshFunc
(
ec2conn
,
s
.
instance
),
Refresh
:
InstanceStateRefreshFunc
(
ec2conn
,
s
.
instance
.
InstanceId
),
Target
:
"terminated"
,
}
...
...
builder/amazon/ebs/step_stop_instance.go
View file @
296f8286
...
...
@@ -40,7 +40,7 @@ func (s *stepStopInstance) Run(state multistep.StateBag) multistep.StepAction {
stateChange
:=
awscommon
.
StateChangeConf
{
Pending
:
[]
string
{
"running"
,
"stopping"
},
Target
:
"stopped"
,
Refresh
:
awscommon
.
InstanceStateRefreshFunc
(
ec2conn
,
instance
),
Refresh
:
awscommon
.
InstanceStateRefreshFunc
(
ec2conn
,
instance
.
InstanceId
),
StepState
:
state
,
}
_
,
err
=
awscommon
.
WaitForState
(
&
stateChange
)
...
...
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