Skip to content

Commit

Permalink
feat(hatchery/k8s): force pull if latest (#5405)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesnault authored Sep 2, 2020
1 parent 5dec37d commit 2e409b2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions engine/hatchery/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)),
Expand Down

0 comments on commit 2e409b2

Please sign in to comment.