Skip to content

Retrying each pull_policy not working after upgrading to 17.3.1

Summary

https://docs.gitlab.com/runner/executors/kubernetes/#set-a-pull-policy Gitlab runner, with kubernetes executor, does not retry each pull policy anymore. In the past, the runner will retry to pull the image for each pull_policy from the list. On the latest version, the job does not retry anymore, if the image is not there it just fails from the first attempt.

Steps to reproduce

Specify multiple pull policies when deploying the gitlab runner. Then, create a pipeline with a job with a docker image which does not exist.

Actual behavior

The job fails from the first attempt of trying to pull the image

Expected behavior

The job used to retry for each pull_policy from the list

Relevant logs and/or screenshots

job log
Running with gitlab-runner 17.3.1 (66269445)
  on ""
Resolving secrets
Preparing the "kubernetes" executor
00:00
"ServiceAccount" overwritten with ""
Using Kubernetes namespace: ""
Using Kubernetes executor with image "" ...
Using attach strategy to execute scripts...
Preparing environment
00:04
Using FF_USE_POD_ACTIVE_DEADLINE_SECONDS, the Pod activeDeadlineSeconds will be set to the job timeout: 1h0m0s...
Waiting for pod "" to be running, status is Pending
WARNING: Event retrieved from the cluster: Failed to pull image "{{random_docker_image}}": rpc error: code = NotFound desc = failed to pull and unpack image "{{random_docker_image}}": failed to resolve reference "{{random_docker_image}}": {{random_docker_image}}: not found
WARNING: Event retrieved from the cluster: Error: ErrImagePull
WARNING: Event retrieved from the cluster: Error: ImagePullBackOff
WARNING: Failed to pull image "{{random_docker_image}}" with policy "": image pull failed: rpc error: code = NotFound desc = failed to pull and unpack image "{{random_docker_image}}": failed to resolve reference "{{random_docker_image}}": {{random_docker_image}}: not found
ERROR: Job failed: prepare environment: waiting for pod running: pulling image "{{random_docker_image}}": image pull failed: rpc error: code = NotFound desc = failed to pull and unpack image "{{random_docker_image}}": failed to resolve reference "{{random_docker_image}}": {{random_docker_image}}: not found. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

Environment description

custom installation with kubernetes executor, version 17.3.1. Helm chart version 0.68.1

config.toml contents
runners:
  # runner configuration, where the multi line strings is evaluated as
  # template so you can specify helm values inside of it.
  #
  # tpl: https://helm.sh/docs/howto/charts_tips_and_tricks/#using-the-tpl-function
  # runner configuration: https://docs.gitlab.com/runner/configuration/advanced-configuration.html
  config: |
    [[runners]]
      output_limit = 300000

      [runners.kubernetes]
        # HACK: Since we are using docker-relay for the executor pods and that sometimes results in a pod in imagepullerr, try pulling 20 times just to be sure
        pull_policy = ["if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present","if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present", "if-not-present"]
        namespace = "{{.Release.Namespace}}"

Used GitLab Runner version

Running with gitlab-runner 17.3.1 (66269445)
Using kubernetes executor ...
Edited by George George