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
c0f64f3a
Commit
c0f64f3a
authored
Jul 30, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/chroot: let go of flock earlier for parallelism
parent
750b7883
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
2 deletions
+55
-2
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+1
-0
builder/amazon/chroot/step_early_unflock.go
builder/amazon/chroot/step_early_unflock.go
+28
-0
builder/amazon/chroot/step_flock.go
builder/amazon/chroot/step_flock.go
+15
-2
builder/amazon/chroot/step_flock_test.go
builder/amazon/chroot/step_flock_test.go
+11
-0
No files found.
builder/amazon/chroot/builder.go
View file @
c0f64f3a
...
...
@@ -127,6 +127,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
StepPrepareDevice
{},
&
StepCreateVolume
{},
&
StepAttachVolume
{},
&
StepEarlyUnflock
{},
&
StepMountDevice
{},
&
StepMountExtra
{},
&
StepCopyFiles
{},
...
...
builder/amazon/chroot/step_early_unflock.go
0 → 100644
View file @
c0f64f3a
package
chroot
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
)
// StepEarlyUnflock unlocks the flock.
type
StepEarlyUnflock
struct
{}
func
(
s
*
StepEarlyUnflock
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
cleanup
:=
state
[
"flock_cleanup"
]
.
(
Cleanup
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
log
.
Println
(
"Unlocking file lock..."
)
if
err
:=
cleanup
.
CleanupFunc
(
state
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error unlocking file lock: %s"
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
return
multistep
.
ActionContinue
}
func
(
s
*
StepEarlyUnflock
)
Cleanup
(
state
map
[
string
]
interface
{})
{}
builder/amazon/chroot/step_flock.go
View file @
c0f64f3a
...
...
@@ -10,6 +10,9 @@ import (
)
// StepFlock provisions the instance within a chroot.
//
// Produces:
// flock_cleanup Cleanup - To perform early cleanup
type
StepFlock
struct
{
fh
*
os
.
File
}
...
...
@@ -46,14 +49,24 @@ func (s *StepFlock) Run(state map[string]interface{}) multistep.StepAction {
// the lock.
s
.
fh
=
f
state
[
"flock_cleanup"
]
=
s
return
multistep
.
ActionContinue
}
func
(
s
*
StepFlock
)
Cleanup
(
state
map
[
string
]
interface
{})
{
s
.
CleanupFunc
(
state
)
}
func
(
s
*
StepFlock
)
CleanupFunc
(
state
map
[
string
]
interface
{})
error
{
if
s
.
fh
==
nil
{
return
return
nil
}
log
.
Printf
(
"Unlocking: %s"
,
s
.
fh
.
Name
())
unlockFile
(
s
.
fh
)
if
err
:=
unlockFile
(
s
.
fh
);
err
!=
nil
{
return
err
}
s
.
fh
=
nil
return
nil
}
builder/amazon/chroot/step_flock_test.go
0 → 100644
View file @
c0f64f3a
package
chroot
import
"testing"
func
TestFlockCleanupFunc_ImplementsCleanupFunc
(
t
*
testing
.
T
)
{
var
raw
interface
{}
raw
=
new
(
StepFlock
)
if
_
,
ok
:=
raw
.
(
Cleanup
);
!
ok
{
t
.
Fatalf
(
"cleanup func should be a CleanupFunc"
)
}
}
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