mirror of https://github.com/docker/docs.git
Skip always pulling images on integration tests
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> (cherry picked from commit e2226223e614716749cdb7701a130c7449f5f854) Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
236317fa56
commit
13e82f23c8
|
@ -2,6 +2,7 @@ package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||||
"github.com/docker/engine-api/types"
|
"github.com/docker/engine-api/types"
|
||||||
|
@ -89,39 +90,41 @@ func (r *controller) Prepare(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.pulled == nil {
|
if os.Getenv("DOCKER_SERVICE_PREFER_OFFLINE_IMAGE") != "1" {
|
||||||
// Fork the pull to a different context to allow pull to continue
|
if r.pulled == nil {
|
||||||
// on re-entrant calls to Prepare. This ensures that Prepare can be
|
// Fork the pull to a different context to allow pull to continue
|
||||||
// idempotent and not incur the extra cost of pulling when
|
// on re-entrant calls to Prepare. This ensures that Prepare can be
|
||||||
// cancelled on updates.
|
// idempotent and not incur the extra cost of pulling when
|
||||||
var pctx context.Context
|
// cancelled on updates.
|
||||||
|
var pctx context.Context
|
||||||
|
|
||||||
r.pulled = make(chan struct{})
|
r.pulled = make(chan struct{})
|
||||||
pctx, r.cancelPull = context.WithCancel(context.Background()) // TODO(stevvooe): Bind a context to the entire controller.
|
pctx, r.cancelPull = context.WithCancel(context.Background()) // TODO(stevvooe): Bind a context to the entire controller.
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(r.pulled)
|
defer close(r.pulled)
|
||||||
r.pullErr = r.adapter.pullImage(pctx) // protected by closing r.pulled
|
r.pullErr = r.adapter.pullImage(pctx) // protected by closing r.pulled
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
case <-r.pulled:
|
case <-r.pulled:
|
||||||
if r.pullErr != nil {
|
if r.pullErr != nil {
|
||||||
// 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
|
||||||
// error out.
|
// error out.
|
||||||
//
|
//
|
||||||
// This gives us some nice behavior where we use up to date versions of
|
// This gives us some nice behavior where we use up to date versions of
|
||||||
// mutable tags, but will still run if the old image is available but a
|
// mutable tags, but will still run if the old image is available but a
|
||||||
// registry is down.
|
// registry is down.
|
||||||
//
|
//
|
||||||
// If you don't want this behavior, lock down your image to an
|
// If you don't want this behavior, lock down your image to an
|
||||||
// immutable tag or digest.
|
// immutable tag or digest.
|
||||||
log.G(ctx).WithError(r.pullErr).Error("pulling image failed")
|
log.G(ctx).WithError(r.pullErr).Error("pulling image failed")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
||||||
|
|
||||||
args = append(args, providedArgs...)
|
args = append(args, providedArgs...)
|
||||||
d.cmd = exec.Command(dockerdBinary, args...)
|
d.cmd = exec.Command(dockerdBinary, args...)
|
||||||
|
d.cmd.Env = append(os.Environ(), "DOCKER_SERVICE_PREFER_OFFLINE_IMAGE=1")
|
||||||
d.cmd.Stdout = out
|
d.cmd.Stdout = out
|
||||||
d.cmd.Stderr = out
|
d.cmd.Stderr = out
|
||||||
d.logFile = out
|
d.logFile = out
|
||||||
|
|
Loading…
Reference in New Issue