Skip to content

CI: Ensure file permissions are respected

Mitchell Nielsen requested to merge ci-runner-disable-umask into master

What does this MR do?

Depends on !1145 (merged).

CI: Ensure file permissions are respected

Ensures that file permissions are not modified by the GitLab Runner's
umask setting. This was causing file permissions to change unexpectedly,
including some configuration files being COPY-ed in with 0666 instead of
0644 as specified with the `install` commands.

Related to:
- https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1736
- https://gitlab.com/gitlab-org/charts/gitlab/-/issues/3797

Feature flag is documented here:
https://docs.gitlab.com/runner/configuration/feature-flags.html#available-feature-flags:

>>>
If enabled will remove the usage of umask 0000 call for jobs executed with docker
executor. Instead Runner will try to discover the UID and GID of the user configured
for the image used by the build container and will change the ownership of the working
directory and files by running the chmod command in the predefined container (after
updating sources, restoring cache and downloading artifacts). POSIX utility id must be
installed and operational in the build image for this feature flag. Runner will execute
id with options -u and -g to retrieve the UID and GID.
>>>

Changelog: fixed

Related issues

Related to gitlab-org/gitlab-runner#1736 (closed)

Related to gitlab-org/charts/gitlab#3797 (closed)

Testing

Ensuring feature flag is enabled

https://gitlab.com/gitlab-org/build/CNG/-/jobs/3112108634#L3

Running with gitlab-runner 15.4.0~beta.18.gdf3903fc (df3903fc)
  on green-3.private.runners-manager.gitlab.com/gitlab.com/gitlab-org QuQPoFsC
  feature flags: FF_NETWORK_PER_BUILD:true, FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR:true, FF_USE_IMPROVED_URL_MASKING:true

Ensuring file permissions are respected

master: permissions are 666 (incorrect)

$ dr registry.gitlab.com/gitlab-org/build/cng/gitaly:master ls -l /etc/gitaly/config.toml
Begin parsing .erb templates from /etc/gitaly
-rw-rw-rw- 1 root root 1388 Sep 30 04:02 /etc/gitaly/config.toml

MR branch: permissions are are 644 (correct)

$ dr registry.gitlab.com/gitlab-org/build/cng/gitaly:ci-runner-disable-umask ls -l /etc/gitaly/config.toml
Begin parsing .erb templates from /etc/gitaly
-rw-r--r-- 1 root root 1388 Sep 30 18:31 /etc/gitaly/config.toml

Downstream Charts pipeline

Triggered pipeline: https://gitlab.com/gitlab-org/charts/gitlab/-/pipelines/657011268

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion

Required

  • Merge Request Title, and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Integration tests added to GitLab QA
  • The impact any change in container size has should be evaluated
Edited by Mitchell Nielsen

Merge request reports