Skip to content

Commit

Permalink
engine: exclude CreateEmptyVolumeError from retry
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelkarp committed Sep 12, 2017
1 parent 9cf7d4b commit cb1c9ff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion agent/api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type NamedError interface {
ErrorName() string
}

// NamedError is a wrapper type for 'error' which adds an optional name and provides a symetric marshal/unmarshal
// NamedError is a wrapper type for 'error' which adds an optional name and provides a symmetric marshal/unmarshal
type DefaultNamedError struct {
Err string `json:"error"`
Name string `json:"name"`
Expand Down
2 changes: 1 addition & 1 deletion agent/engine/docker_container_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (dg *dockerGoClient) pullImage(image string, authData *api.RegistryAuthenti
if image == emptyvolume.Image+":"+emptyvolume.Tag {
scratchErr := dg.createScratchImageIfNotExists()
if scratchErr != nil {
return &api.DefaultNamedError{Name: "CreateEmptyVolumeError", Err: "Could not create empty volume " + scratchErr.Error()}
return CreateEmptyVolumeError{scratchErr}
}
return nil
}
Expand Down
17 changes: 17 additions & 0 deletions agent/engine/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,23 @@ func (err CannotPullECRContainerError) Retry() bool {
return false
}

type CreateEmptyVolumeError struct {
fromError error
}

func (err CreateEmptyVolumeError) Error() string {
return err.fromError.Error()
}

func (err CreateEmptyVolumeError) ErrorName() string {
return "CreateEmptyVolumeError"
}

// Retry fulfills the utils.Retrier interface and allows retries to be skipped by utils.Retry* functions
func (err CreateEmptyVolumeError) Retry() bool {
return false
}

// CannotCreateContainerError indicates any error when trying to create a container
type CannotCreateContainerError struct {
fromError error
Expand Down

0 comments on commit cb1c9ff

Please sign in to comment.