Reconfigure SecretsManagerClient after each code reload

What does this MR do and why?

SecretsManagement::SecretsManagerClient memoises its configuration on the class, and ee/config/initializers/secrets_manager.rb populated it once at boot. The class lives in ee/lib, which Zeitwerk reloads in development, so the first code change after boot replaced the class with one whose configuration had a nil host, and every OpenBao call raised ArgumentError: bad argument (expected URI object or URI string) until the server was restarted. Since Groups::SecretsController began logging into OpenBao during the page load, this surfaces as a 500 on the group Secrets page.

This MR runs the configuration inside Rails.application.config.to_prepare, which Rails executes again after every reload, matching how ee/config/initializers/policy_store.rb already handles the same problem. Production and test never reload, so nothing changes there. A spec proves the configuration is reapplied when the reloader's prepare callbacks run.

No changelog entry: the change only affects development mode.

References

Differences

Before: In GDK, after any Rails code reload, visiting a group's Secrets page returns a 500 and every SecretsManagerClient call raises until restart.

After: The client is reconfigured on each reload and the page keeps working.

How to set up and validate locally

  1. Start GDK with OpenBao and open a group's Settings > Secrets page.
  2. Touch any file under ee/lib (or switch branches) and reload the page.
  3. On master the page 500s with ArgumentError; with this MR it renders.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jeston Singh

Merge request reports

Loading
Loading