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
6d28ee93
Commit
6d28ee93
authored
Apr 21, 2015
by
duftler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete GCE disk on SIGINT.
parent
419f3271
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
builder/googlecompute/step_create_instance.go
builder/googlecompute/step_create_instance.go
+23
-0
builder/googlecompute/step_create_instance_test.go
builder/googlecompute/step_create_instance_test.go
+8
-1
No files found.
builder/googlecompute/step_create_instance.go
View file @
6d28ee93
...
...
@@ -125,6 +125,29 @@ func (s *StepCreateInstance) Cleanup(state multistep.StateBag) {
"Error: %s"
,
name
,
err
))
}
ui
.
Message
(
"Instance has been deleted!"
)
state
.
Put
(
"instance_name"
,
""
)
// Deleting the instance does not remove the boot disk. This cleanup removes
// the disk.
ui
.
Say
(
"Deleting disk..."
)
errCh
,
err
=
driver
.
DeleteDisk
(
config
.
Zone
,
config
.
DiskName
)
if
err
==
nil
{
select
{
case
err
=
<-
errCh
:
case
<-
time
.
After
(
config
.
stateTimeout
)
:
err
=
errors
.
New
(
"time out while waiting for disk to delete"
)
}
}
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error deleting disk. Please delete it manually.
\n\n
"
+
"Name: %s
\n
"
+
"Error: %s"
,
config
.
InstanceName
,
err
))
}
ui
.
Message
(
"Disk has been deleted!"
)
return
}
builder/googlecompute/step_create_instance_test.go
View file @
6d28ee93
...
...
@@ -39,7 +39,14 @@ func TestStepCreateInstance(t *testing.T) {
t
.
Fatal
(
"should've deleted instance"
)
}
if
driver
.
DeleteInstanceZone
!=
config
.
Zone
{
t
.
Fatalf
(
"bad zone: %#v"
,
driver
.
DeleteInstanceZone
)
t
.
Fatalf
(
"bad instance zone: %#v"
,
driver
.
DeleteInstanceZone
)
}
if
driver
.
DeleteDiskName
!=
config
.
InstanceName
{
t
.
Fatal
(
"should've deleted disk"
)
}
if
driver
.
DeleteDiskZone
!=
config
.
Zone
{
t
.
Fatalf
(
"bad disk zone: %#v"
,
driver
.
DeleteDiskZone
)
}
}
...
...
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