Skip to content

Commit

Permalink
Merge branch 'master' into aj-v4.0.1-prep
Browse files Browse the repository at this point in the history
* master:
  remove unused import
  improve logging around buildsh-trace
  • Loading branch information
soulshake committed Aug 22, 2018
2 parents bfc0fdd + c4fa506 commit e02aee0
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions backend/backend.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package backend

import (
"errors"
"fmt"
"sort"
"sync"
Expand All @@ -13,6 +14,8 @@ var (
backendRegistryMutex sync.Mutex
)

var ErrDownloadTraceNotImplemented = errors.New("DownloadTrace not implemented")

// Backend wraps up an alias, backend provider help, and a factory func for a
// given backend provider wheee
type Backend struct {
Expand Down
2 changes: 1 addition & 1 deletion backend/cloudbrain.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ func (i *cbInstance) RunScript(ctx gocontext.Context, output io.Writer) (*RunRes
}

func (i *cbInstance) DownloadTrace(ctx gocontext.Context) ([]byte, error) {
return nil, errors.New("DownloadTrace not implemented")
return nil, ErrDownloadTraceNotImplemented
}

func (i *cbInstance) Stop(ctx gocontext.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion backend/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ func (i *dockerInstance) runScriptSSH(ctx gocontext.Context, output io.Writer) (
}

func (i *dockerInstance) DownloadTrace(ctx gocontext.Context) ([]byte, error) {
return nil, errors.New("DownloadTrace not implemented")
return nil, ErrDownloadTraceNotImplemented
}

func (i *dockerInstance) Stop(ctx gocontext.Context) error {
Expand Down
3 changes: 1 addition & 2 deletions backend/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package backend

import (
"context"
"errors"
"io"
"time"

Expand Down Expand Up @@ -82,7 +81,7 @@ func (i *fakeInstance) RunScript(ctx context.Context, writer io.Writer) (*RunRes
}

func (i *fakeInstance) DownloadTrace(ctx context.Context) ([]byte, error) {
return nil, errors.New("DownloadTrace not implemented")
return nil, ErrDownloadTraceNotImplemented
}

func (i *fakeInstance) Stop(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion backend/jupiterbrain.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func (i *jupiterBrainInstance) RunScript(ctx gocontext.Context, output io.Writer
}

func (i *jupiterBrainInstance) DownloadTrace(ctx gocontext.Context) ([]byte, error) {
return nil, errors.New("DownloadTrace not implemented")
return nil, ErrDownloadTraceNotImplemented
}

func (i *jupiterBrainInstance) Stop(ctx gocontext.Context) error {
Expand Down
3 changes: 1 addition & 2 deletions backend/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package backend

import (
"bytes"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -124,7 +123,7 @@ func (i *localInstance) RunScript(ctx gocontext.Context, writer io.Writer) (*Run
}

func (i *localInstance) DownloadTrace(ctx gocontext.Context) ([]byte, error) {
return nil, errors.New("DownloadTrace not implemented")
return nil, ErrDownloadTraceNotImplemented
}

func (i *localInstance) Stop(ctx gocontext.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion backend/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ func (i *osInstance) RunScript(ctx gocontext.Context, output io.Writer) (*RunRes
}

func (i *osInstance) DownloadTrace(ctx gocontext.Context) ([]byte, error) {
return nil, errors.New("DownloadTrace not implemented")
return nil, ErrDownloadTraceNotImplemented
}

func (i *osInstance) Stop(ctx gocontext.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion ssh/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (c *sshConnection) DownloadFile(path string) ([]byte, error) {

_, err = sftp.Lstat(path)
if err != nil {
return nil, errors.Wrap(err, "couldn't stat file (it may be missing)")
return nil, errors.Wrap(err, "couldn't stat file")
}

f, err := sftp.OpenFile(path, os.O_RDONLY)
Expand Down
10 changes: 10 additions & 0 deletions step_download_trace.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package worker

import (
"os"
"time"

gocontext "context"

"github.com/mitchellh/multistep"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/travis-ci/worker/backend"
"github.com/travis-ci/worker/context"
Expand Down Expand Up @@ -36,6 +38,14 @@ func (s *stepDownloadTrace) Run(state multistep.StateBag) multistep.StepAction {

buf, err := instance.DownloadTrace(ctx)
if err != nil {
if err == backend.ErrDownloadTraceNotImplemented || os.IsNotExist(errors.Cause(err)) {
logger.WithFields(logrus.Fields{
"err": err,
}).Info("skipping trace download")

return multistep.ActionContinue
}

metrics.Mark("worker.job.trace.download.error")

logger.WithFields(logrus.Fields{
Expand Down

0 comments on commit e02aee0

Please sign in to comment.