Skip always pulling images on integration tests

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2016-06-20 17:44:45 -07:00
parent 815b2ffb41
commit e2226223e6
2 changed files with 17 additions and 14 deletions

View File

@ -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"
@ -84,6 +85,7 @@ func (r *controller) Prepare(ctx context.Context) error {
return err return err
} }
if os.Getenv("DOCKER_SERVICE_PREFER_OFFLINE_IMAGE") != "1" {
if err := r.adapter.pullImage(ctx); err != nil { if err := r.adapter.pullImage(ctx); err != 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
@ -98,6 +100,7 @@ func (r *controller) Prepare(ctx context.Context) error {
// immutable tag or digest. // immutable tag or digest.
log.G(ctx).WithError(err).Error("pulling image failed") log.G(ctx).WithError(err).Error("pulling image failed")
} }
}
if err := r.adapter.create(ctx, r.backend); err != nil { if err := r.adapter.create(ctx, r.backend); err != nil {
if isContainerCreateNameConflict(err) { if isContainerCreateNameConflict(err) {

View File

@ -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