Skip to content

Resolve "Jobs for ruby fail with apt-errors"

georg requested to merge 316-ci-fix-apt-caching into master

The code introduced in ac20c72b was buggy, because it only checked the existence of the APT cache directory. If two containers were started at the same time, sometimes the code would run into a race condition; one of the containers would update the APT package cache, the second would assume, as the directory did exist, that an update of the package cache was unneeded, accordingly, installing packages in the second container failed.

This commit introduces a better check: It doesn't rely on the existence of the directory, but uses 'find' to check the 'mtime' of the contained list files. If there are none (in case the GitLab CI cache is empty), or the last package update run was (more than) 14 days ago, the package cache is updated.

To make the caching working reliable, another change on the GitLab Runner was needed. In the config, 'cache_dir' was set to a directory on the host and 'volumes' was accordingly extended via adding this directory. Unfortunately, the GitLab CI docs are quite sparse in this regard, so it took a while to figure this out.

This change was tested several times against different (force-pushed) branches and with "cold and hot" cache.

On top, this commit clarifies the naming of the environment variables which are used in the APT config.

Closes #316 (closed)

Edited by georg

Merge request reports