Add No docker prune env var

What does this MR do and why?

Closes #39415 (closed)

During apt/rpm package install or upgrade, the post-install scripts unconditionally call clear-docker-cache prune. This is surprising behaviour: users who do not want docker pruned during an upgrade have no way to opt out, and the prune can stall upgrades for a long time.

Root cause

packaging/scripts/postinst.deb and packaging/scripts/postinst.rpm call /usr/share/gitlab-runner/clear-docker-cache prune with no guard, so it always runs.

Fix

Follow the existing USE_INIT_USER pattern in post-install: check for an env var (NO_DOCKER_PRUNE) and skip the prune when it is set. The default behaviour (prune runs) is preserved so existing users who rely on it are not broken.

To skip the prune for a single upgrade:

NO_DOCKER_PRUNE=1 apt-get upgrade gitlab-runner

To skip it permanently (until the env var is unset in the calling environment), export it in the shell or init system that invokes the package manager.

Merge request reports

Loading