Merge branch 'master' of github.com:mitchellh/packer into skip_nat_port
This commit is contained in:
commit
a942af51cc
@ -14,7 +14,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type comm struct {
|
||||
@ -117,45 +116,6 @@ func (c *comm) Start(cmd *packer.RemoteCmd) (err error) {
|
||||
close(doneCh)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
failures := 0
|
||||
for {
|
||||
log.Printf("[DEBUG] Background SSH connection checker is testing")
|
||||
dummy, err := c.config.Connection()
|
||||
if err == nil {
|
||||
failures = 0
|
||||
dummy.Close()
|
||||
}
|
||||
|
||||
select {
|
||||
case <-doneCh:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Printf("background SSH connection checker failure: %s", err)
|
||||
failures += 1
|
||||
}
|
||||
|
||||
if failures < 5 {
|
||||
time.Sleep(5 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
// Acquire a lock in order to modify session state
|
||||
sessionLock.Lock()
|
||||
defer sessionLock.Unlock()
|
||||
|
||||
// Kill the connection and mark that we timed out.
|
||||
log.Printf("Too many SSH connection failures. Killing it!")
|
||||
c.conn.Close()
|
||||
timedOut = true
|
||||
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ type BuildServer struct {
|
||||
|
||||
type BuildPrepareResponse struct {
|
||||
Warnings []string
|
||||
Error error
|
||||
Error *BasicError
|
||||
}
|
||||
|
||||
func (b *build) Name() (result string) {
|
||||
@ -34,8 +34,12 @@ func (b *build) Prepare() ([]string, error) {
|
||||
if cerr := b.client.Call("Build.Prepare", new(interface{}), &resp); cerr != nil {
|
||||
return nil, cerr
|
||||
}
|
||||
var err error = nil
|
||||
if resp.Error != nil {
|
||||
err = resp.Error
|
||||
}
|
||||
|
||||
return resp.Warnings, resp.Error
|
||||
return resp.Warnings, err
|
||||
}
|
||||
|
||||
func (b *build) Run(ui packer.Ui, cache packer.Cache) ([]packer.Artifact, error) {
|
||||
@ -90,7 +94,7 @@ func (b *BuildServer) Prepare(args *interface{}, resp *BuildPrepareResponse) err
|
||||
warnings, err := b.build.Prepare()
|
||||
*resp = BuildPrepareResponse{
|
||||
Warnings: warnings,
|
||||
Error: err,
|
||||
Error: NewBasicError(err),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -25,14 +25,14 @@ type PostProcessorConfigureArgs struct {
|
||||
}
|
||||
|
||||
type PostProcessorProcessResponse struct {
|
||||
Err error
|
||||
Err *BasicError
|
||||
Keep bool
|
||||
StreamId uint32
|
||||
}
|
||||
|
||||
func (p *postProcessor) Configure(raw ...interface{}) (err error) {
|
||||
args := &PostProcessorConfigureArgs{Configs: raw}
|
||||
if cerr := p.client.Call("PostProcessor.Configure", args, &err); cerr != nil {
|
||||
if cerr := p.client.Call("PostProcessor.Configure", args, new(interface{})); cerr != nil {
|
||||
err = cerr
|
||||
}
|
||||
|
||||
@ -67,13 +67,9 @@ func (p *postProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Art
|
||||
return client.Artifact(), response.Keep, nil
|
||||
}
|
||||
|
||||
func (p *PostProcessorServer) Configure(args *PostProcessorConfigureArgs, reply *error) error {
|
||||
*reply = p.p.Configure(args.Configs...)
|
||||
if *reply != nil {
|
||||
*reply = NewBasicError(*reply)
|
||||
}
|
||||
|
||||
return nil
|
||||
func (p *PostProcessorServer) Configure(args *PostProcessorConfigureArgs, reply *interface{}) error {
|
||||
err := p.p.Configure(args.Configs...)
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PostProcessorServer) PostProcess(streamId uint32, reply *PostProcessorProcessResponse) error {
|
||||
@ -92,12 +88,8 @@ func (p *PostProcessorServer) PostProcess(streamId uint32, reply *PostProcessorP
|
||||
go server.Serve()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
err = NewBasicError(err)
|
||||
}
|
||||
|
||||
*reply = PostProcessorProcessResponse{
|
||||
Err: err,
|
||||
Err: NewBasicError(err),
|
||||
Keep: keep,
|
||||
StreamId: streamId,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user