From 91e8eb0c70b534bf215e36e1a59377c59e47bd3e Mon Sep 17 00:00:00 2001 From: David C Wang Date: Mon, 24 Sep 2018 21:42:34 +0000 Subject: [PATCH] Fixed docker update pull race condition * Prior would attempt to pull the existing image. * Changed to pull the new version --- pkg/kdk/pull.go | 7 ++++++- pkg/kdk/update.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/kdk/pull.go b/pkg/kdk/pull.go index 7764d1b..6446415 100644 --- a/pkg/kdk/pull.go +++ b/pkg/kdk/pull.go @@ -24,7 +24,12 @@ import ( ) func Pull(cfg *KdkEnvConfig) error { - out, err := cfg.DockerClient.ImagePull(cfg.Ctx, cfg.ImageCoordinates(), types.ImagePullOptions{}) + return pullImage(cfg, cfg.ImageCoordinates()) +} + +func pullImage(cfg *KdkEnvConfig, imageCoordinates string) error { + + out, err := cfg.DockerClient.ImagePull(cfg.Ctx, imageCoordinates, types.ImagePullOptions{}) if err != nil { return err } diff --git a/pkg/kdk/update.go b/pkg/kdk/update.go index 513e9be..2aab339 100644 --- a/pkg/kdk/update.go +++ b/pkg/kdk/update.go @@ -113,7 +113,7 @@ func Update(cfg *KdkEnvConfig) { if needsUpdateImage(cfg) { log.Info("Updating KDK image") - err := updateImage(cfg) + err := pullImage(cfg, cfg.ConfigFile.AppConfig.ImageRepository + ":" + latestReleaseVersion) if err != nil { log.WithField("error", err).Fatal("Failed to update KDK image") }