department-of-veterans-affairs / abd-vro

To get Veterans benefits in minutes, VRO software uses health evidence data to help fast track disability claims.
Other
17 stars 6 forks source link

Fix ruby file loading issue for metric logger #3149

Closed lisac closed 3 days ago

lisac commented 4 days ago

What was the problem?

Readiness probe is failing for deployed versions of svc-bgs-api (have only deployed to pre-prod environments; seeing this error consistently).

Readiness probe failed: /usr/local/lib/ruby/3.3.0/bundled_gems.rb:74:in `require': cannot load such file -- metric_logger (LoadError) from /usr/local/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require' from /app/lib/bgs_client.rb:6:in `<top (required)>' from /app/healthcheck/readiness_script.rb:6:in `require_relative' from /app/healthcheck/readiness_script.rb:6:in `<main>'

The metric_logger in question is not an external gem, and was recently introduced - this is the first time we're trying to deploy it. It might be that we should be using require_relative to load it, instead of require. Going off of this reasoning:

require is usually called when requiring gems loaded in gemfile. Though require can be used to both execute gems and external dependencies, the preferable method to load relative paths is require_relative. require_relative is a subset of require and is a convenient method to use when you are referring to a file that is relative to the current file you are working on (basically, within the same project directory). (source: Understanding Require vs. Require_relative vs. Require_all)

The solution

Use require_relative instead of require for loading metric_logger.

How I tested this

note on deploying this to production

Likely 7/3. I'm not prepared to troubleshoot if the deployment fails today.

github-actions[bot] commented 4 days ago

Test Results

116 tests  ±0   116 :white_check_mark: ±0   35s :stopwatch: ±0s  34 suites ±0     0 :zzz: ±0   34 files   ±0     0 :x: ±0 

Results for commit b1f9443e. ± Comparison against base commit 176b540b.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 4 days ago

JaCoCo Test Coverage

Overall Project 67.56% :x:

There is no coverage information present for the Files changed