From 2e409b284f3528f1cace77f0b9b19e69c7047da3 Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Wed, 2 Sep 2020 11:39:35 +0200 Subject: [PATCH] feat(hatchery/k8s): force pull if latest (#5405) --- engine/hatchery/kubernetes/kubernetes.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/engine/hatchery/kubernetes/kubernetes.go b/engine/hatchery/kubernetes/kubernetes.go index e33bd69e04..e8ee0095c3 100644 --- a/engine/hatchery/kubernetes/kubernetes.go +++ b/engine/hatchery/kubernetes/kubernetes.go @@ -331,6 +331,11 @@ func (h *HatcheryKubernetes) SpawnWorker(ctx context.Context, spawnArgs hatchery i++ } + pullPolicy := "IfNotPresent" + if strings.HasSuffix(spawnArgs.Model.ModelDocker.Image, ":latest") { + pullPolicy = "Always" + } + var gracePeriodSecs int64 podSchema := apiv1.Pod{ ObjectMeta: metav1.ObjectMeta{ @@ -348,11 +353,12 @@ func (h *HatcheryKubernetes) SpawnWorker(ctx context.Context, spawnArgs hatchery TerminationGracePeriodSeconds: &gracePeriodSecs, Containers: []apiv1.Container{ { - Name: spawnArgs.WorkerName, - Image: spawnArgs.Model.ModelDocker.Image, - Env: envs, - Command: strings.Fields(spawnArgs.Model.ModelDocker.Shell), - Args: []string{cmd}, + Name: spawnArgs.WorkerName, + Image: spawnArgs.Model.ModelDocker.Image, + ImagePullPolicy: apiv1.PullPolicy(pullPolicy), + Env: envs, + Command: strings.Fields(spawnArgs.Model.ModelDocker.Shell), + Args: []string{cmd}, Resources: apiv1.ResourceRequirements{ Requests: apiv1.ResourceList{ apiv1.ResourceMemory: resource.MustParse(fmt.Sprintf("%d", memory)),