fix: check-config correctly detects mattermost[...] removal before upgrading to 19.0

What does this MR do and why?

Fixes gitlab-ctl check-config --version 19.0.x silently passing when mattermost[...] keys are present in gitlab.rb, even though reconfigure after upgrading to 19.0 aborts with Removed configurations found in gitlab.rb.

Root cause

Two compounding issues:

1. check_config.rb read only node_json['normal']

The node JSON has two sections: default (cookbook-populated defaults) and normal (user-set values). check_config.rb was reading only normal. For top-level component keys like mattermost, the cookbook registers the attribute via attribute('mattermost') in the config DSL, which means ConfigMash always initialises it to an empty hash in normal — even when the user has set values — because the user values get merged into the full hash at a different layer. The fix merges default + normal (same as get_node_attributes) so the full config is available.

2. applicable_deprecations couldn't distinguish user config from cookbook defaults

With the merged config, mattermost is always a large non-empty hash (full of cookbook defaults), so the existing !(value.nil? || value.empty?) filter would fire even for instances that never configured Mattermost. The fix adds a user_set_only: true flag to deprecation entries for components that are always present in cookbook defaults (mattermost, spamcheck). When this flag is set and a user_config (raw normal slice) is provided, applicable_deprecations checks the user config instead of the merged config to determine whether the key was explicitly set.

Changes

  • check_config.rb: merge default + normal before passing to check_config; pass raw normal as user_config: keyword arg.
  • deprecations.rb: add user_set_only: true to mattermost and spamcheck entries; update applicable_deprecations and check_config signatures to accept and use user_config:.
  • deprecations_spec.rb: add specs for the cookbook-defaults-only case (should not warn) and the user-set case (should warn).

Checklist

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Tests added.

Closes gitlab-ctl check-config fails to detect matterm... (#9916)
Related support ticket: https://gitlab.zendesk.com/agent/tickets/725485

Edited by Niklas Janz

Merge request reports

Loading