Merge pull request #33117 from aaronlehmann/digest-pin-context-17.03
[17.03.2] cluster: Renew the context after communicating with the registry
This commit is contained in:
commit
7f394b8b35
2 changed files with 21 additions and 0 deletions
|
@ -32,6 +32,7 @@ be found.
|
|||
* Retry failed network allocations less aggressively [docker/swarmkit#2021](https://github.com/docker/swarmkit/pull/2021)
|
||||
* Avoid network allocation for tasks that are no longer running [docker/swarmkit#2017](https://github.com/docker/swarmkit/pull/2017)
|
||||
* Bookkeeping fixes inside network allocator allocator [docker/swarmkit#2019](https://github.com/docker/swarmkit/pull/2019) [docker/swarmkit#2020](https://github.com/docker/swarmkit/pull/2020)
|
||||
* Avoid timing out service create or update when a registry is slow to respond [#31861](https://github.com/docker/docker/pull/31861)
|
||||
|
||||
### Windows
|
||||
|
||||
|
|
|
@ -1119,6 +1119,16 @@ func (c *Cluster) CreateService(s types.ServiceSpec, encodedAuth string) (*apity
|
|||
} else {
|
||||
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 newCancel func()
|
||||
ctx, newCancel = c.getRequestContext()
|
||||
defer newCancel()
|
||||
}
|
||||
|
||||
r, err := c.client.CreateService(ctx, &swarmapi.CreateServiceRequest{Spec: &serviceSpec})
|
||||
|
@ -1230,6 +1240,16 @@ func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec typ
|
|||
} else {
|
||||
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 create a service
|
||||
// if the registry is slow or unresponsive.
|
||||
var newCancel func()
|
||||
ctx, newCancel = c.getRequestContext()
|
||||
defer newCancel()
|
||||
}
|
||||
|
||||
_, err = c.client.UpdateService(
|
||||
|
|
Loading…
Reference in a new issue