瀏覽代碼

Merge pull request #25030 from stevvooe/allow-cancellation-propagation

swarm/controller: allow cancellation to propagate
Tibor Vass 9 年之前
父節點
當前提交
a6a261261d
共有 2 個文件被更改,包括 10 次插入1 次删除
  1. 5 0
      daemon/cluster/executor/container/controller.go
  2. 5 1
      distribution/errors.go

+ 5 - 0
daemon/cluster/executor/container/controller.go

@@ -87,6 +87,11 @@ func (r *controller) Prepare(ctx context.Context) error {
 
 	if os.Getenv("DOCKER_SERVICE_PREFER_OFFLINE_IMAGE") != "1" {
 		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
 			// 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

+ 5 - 1
distribution/errors.go

@@ -40,7 +40,11 @@ type fallbackError struct {
 
 // Error renders the FallbackError as a 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.