3

I'm using GitLab.com's managed CI runners, and I'd like to run my CI jobs using the if-not-present pull policy to avoid the extra minutes it takes to pull the image for each job. Trying to set that value in the .gitlab-ci.yml file gives me this error:

pull_policy ([if-not-present]) defined in GitLab pipeline config is not one of the allowed_pull_policies ([always])

This led me to the config.toml settings for restricting Docker pull policies, so I created a config.toml file at the root of my repository and tried that. However, I still get the same error.

Is config.toml only available for manual/self-hosted runners? Is there any other way to get past this?


Context

Image selection in .gitlab-ci.yml:

default:
  image:
    name: registry.gitlab.com/myorg/myrepo/ci/builder:latest
    pull_policy: if-not-present

Contents of config.toml:

[[runners]]
  executor = "docker"
  [runners.docker]
    pull_policy = ["if-not-present"]
    allowed_pull_policies = ["always", "if-not-present"]
Stabby
  • 97
  • 1
  • 6

1 Answers1

2

First of all, the config.toml file is not meant to be in your repo but on the runner machine (or container).

But anyways, the always pull policy should not cause image pulls to last minutes if the layers are already cached locally: it just ensures you have the latest version by checking the metadata. If the pulls take minutes, it means that either the layers are not available locally, or the image was actually updated (or that the connection to your container registry is so incredibly slow that just checking the metadata takes minutes, but that is unlikely).

It is very possible that Gitlab's managed runners do not have a way to locally cache layers, and thus there would be no practical difference between the always and if-not-present policies. For instance if you use Gitlab Saas:

A dedicated temporary runner VM hosts and runs each CI job.

(see https://docs.gitlab.com/ee/ci/runners/index.html)

Thus the downloaded layers are discarded as soon as the job finishes.

gpothier
  • 850
  • 6
  • 12