mirror of https://github.com/docker/docs.git
swarm/controller: allow cancellation to propagate
Ensure that cancellation of a pull propagates rather than continuing to container creation. This ensures that the `Prepare` method is properly re-entrant. Signed-off-by: Stephen J Day <stephen.day@docker.com> (cherry picked from commit d99c6b837ffd18ffe5bce801feb4936bf0edd2aa) Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
07735b4f0c
commit
027de801a8
|
@ -85,6 +85,11 @@ func (r *controller) Prepare(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.adapter.pullImage(ctx); err != nil {
|
if err := r.adapter.pullImage(ctx); err != nil {
|
||||||
|
cause := errors.Cause(err)
|
||||||
|
if cause == context.Canceled || cause == context.DeadlineExceeded {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE(stevvooe): We always try to pull the image to make sure we have
|
// NOTE(stevvooe): We always try to pull the image to make sure we have
|
||||||
// the most up to date version. This will return an error, but we only
|
// the most up to date version. This will return an error, but we only
|
||||||
// log it. If the image truly doesn't exist, the create below will
|
// log it. If the image truly doesn't exist, the create below will
|
||||||
|
|
|
@ -40,7 +40,11 @@ type fallbackError struct {
|
||||||
|
|
||||||
// Error renders the FallbackError as a string.
|
// Error renders the FallbackError as a string.
|
||||||
func (f fallbackError) Error() string {
|
func (f fallbackError) Error() string {
|
||||||
return f.err.Error()
|
return f.Cause().Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f fallbackError) Cause() error {
|
||||||
|
return f.err
|
||||||
}
|
}
|
||||||
|
|
||||||
// shouldV2Fallback returns true if this error is a reason to fall back to v1.
|
// shouldV2Fallback returns true if this error is a reason to fall back to v1.
|
||||||
|
|
Loading…
Reference in New Issue