|
@@ -122,6 +122,16 @@ func (c *Cluster) CreateService(s types.ServiceSpec, encodedAuth string) (*apity
|
|
} else {
|
|
} else {
|
|
logrus.Debugf("creating service using supplied digest reference %s", ctnr.Image)
|
|
logrus.Debugf("creating service using supplied digest reference %s", ctnr.Image)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Replace the context with a fresh one.
|
|
|
|
+ // If we timed out while communicating with the
|
|
|
|
+ // registry, then "ctx" will already be expired, which
|
|
|
|
+ // would cause UpdateService below to fail. Reusing
|
|
|
|
+ // "ctx" could make it impossible to create a service
|
|
|
|
+ // if the registry is slow or unresponsive.
|
|
|
|
+ var cancel func()
|
|
|
|
+ ctx, cancel = c.getRequestContext()
|
|
|
|
+ defer cancel()
|
|
}
|
|
}
|
|
|
|
|
|
r, err := state.controlClient.CreateService(ctx, &swarmapi.CreateServiceRequest{Spec: &serviceSpec})
|
|
r, err := state.controlClient.CreateService(ctx, &swarmapi.CreateServiceRequest{Spec: &serviceSpec})
|
|
@@ -212,6 +222,16 @@ func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec typ
|
|
} else {
|
|
} else {
|
|
logrus.Debugf("updating service using supplied digest reference %s", newCtnr.Image)
|
|
logrus.Debugf("updating service using supplied digest reference %s", newCtnr.Image)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Replace the context with a fresh one.
|
|
|
|
+ // If we timed out while communicating with the
|
|
|
|
+ // registry, then "ctx" will already be expired, which
|
|
|
|
+ // would cause UpdateService below to fail. Reusing
|
|
|
|
+ // "ctx" could make it impossible to update a service
|
|
|
|
+ // if the registry is slow or unresponsive.
|
|
|
|
+ var cancel func()
|
|
|
|
+ ctx, cancel = c.getRequestContext()
|
|
|
|
+ defer cancel()
|
|
}
|
|
}
|
|
|
|
|
|
var rollback swarmapi.UpdateServiceRequest_Rollback
|
|
var rollback swarmapi.UpdateServiceRequest_Rollback
|