Skip to content

fix: Explicitly require fileutils in logger

Craig Miskell requested to merge add-fileutils-require into master

What does this MR do and why?

Fixes a bug (or edge case) in runtime/logger.rb that tries to use FileUtils without requiring it, and it fails to do so in at least some locations (perhaps specific ones, like Alpine docker images)

FileUtils was introduced in 435078de and the reference was fixed (with a :: prefix) in 9c9c6646 but there are still cases where this doesn't work (https://gitlab.com/gitlab-com/gl-infra/gitlab-dedicated/instrumentor/-/jobs/2559204983). The failure can be replicated by running an alpine docker image, installing ruby-dev, g++, make, then installing the gem and running it.

The explicit require added here has been tested in that same environment (manual edit) and it fixes the problem.

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. docker run -it alpine:3.15 sh
  2. apk add ruby-dev g++ make
  3. gem install gitlab-qa -v 7.30.0 #latest version at this writing, contains bug
  4. gitlab-qa Test::Instance::Any "EE:14.10.4-ee" https://whatever.com/
    • Failure can be observed: /usr/lib/ruby/gems/3.0.0/gems/gitlab-qa-7.30.0/lib/gitlab/qa/runtime/logger.rb:16:in logger': uninitialized constant FileUtils (NameError)`
  5. Edit /usr/lib/ruby/gems/3.0.0/gems/gitlab-qa-7.30.0/lib/gitlab/qa/runtime/logger.rb and add the "require" in this MR
  6. gitlab-qa Test::Instance::Any "EE:14.10.4-ee" https://whatever.com/
    • Now fails with a complaint about docker, which is fine because we didn't install it. It made it past the failure though.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Craig Miskell

Merge request reports