Switch to ruby slim images for critical path of rspec-ee unit pg* jobs
Context
Looking at #385049 (closed), I've noticed that downloading the ruby:2.7
image takes around 17 seconds in some jobs on the critical path of the rspec-ee unit pg*
jobs (namely retrieve-tests-metadata
and detect-tests
):
- https://gitlab.com/gitlab-org/gitlab/-/jobs/3437305890 (17 seconds)
- https://gitlab.com/gitlab-org/gitlab/-/jobs/3437305893 (18 seconds)
- https://gitlab.com/gitlab-org/gitlab/-/jobs/3437230193 (16 seconds)
- https://gitlab.com/gitlab-org/gitlab/-/jobs/3437167713 (17 seconds)
- https://gitlab.com/gitlab-org/gitlab/-/jobs/3437167716 (17 seconds)
What does this MR do?
Switch the ruby:2.7 image to its slim
counterpart, which is smaller, and therefore will download faster from the dependency proxy.
Difference in size between container images
$ docker images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
ruby 2.7 e337a1b74b67 3 hours ago linux/arm64/v8 845.4 MiB 313.3 MiB
ruby 2.7-alpine3.16 b9b58c6bc64e 54 minutes ago linux/arm64/v8 52.3 MiB 19.7 MiB
ruby 2.7-slim 1e52473bc559 About a minute ago linux/arm64/v8 151.8 MiB 51.2 MiB
Why not alpine?
Alpine doesn't have bash
, and the scripts/rspec_helpers.sh script uses some bashisms (e.g. <<<
, arrays
, ...). GitLab runner won't use bash, even if we install it, because it chooses the shell to use when first downloading the container image (source: gitlab-runner#1758 (comment 16419417)).
I could have rewritten the scripts/rspec_helpers.sh
to be POSIX-compliant, but it felt like too much work for now for the improvement it would bring compared to using slim
images (not to mention we don't have tests for those scripts, which makes refactorings trickier).
Improvements in the job
- Before: 17 seconds on average
- After: 7 seconds on average (jobs: https://gitlab.com/gitlab-org/gitlab/-/jobs/3437964080, https://gitlab.com/gitlab-org/gitlab/-/jobs/3437938185)
We saved 10 seconds per job
Next up
This is a fairly easy change, and with a bit of testing, we could make to most CI jobs using ruby.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #385049 (closed)