Dev: sbd: Check and fix deprecated properties#2159
Conversation
16fbb25 to
efd37a3
Compare
…rap (ClusterLabs#2077)" This reverts commit db68d02, reversing changes made to ce740ef.
efd37a3 to
fc1e727
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nicholasyang2022
left a comment
There was a problem hiding this comment.
Thank you for this PR! Moving towards dynamic, metadata-driven discovery for deprecated properties is a fantastic architectural improvement that will make crmsh much more resilient to upstream Pacemaker changes.
However, during review, I identified a few critical safety concerns regarding how the migration (--fix) is handled, as well as some API design issues that need to be addressed before this can be merged.
Critical/Blocking Issues (Safety)
1. Unsafe Scope of SBD Health Check (crm cluster health sbd --fix)
Currently, utils.get_all_configured_deprecated_properties() fetches all deprecated properties defined in the Pacemaker metadata.
- The Risk: Running
crm cluster health sbd --fixwill now indiscriminately check, migrate, and potentially delete any deprecated cluster property (e.g., legacy quorum policies, placement strategies) across the entire cluster, not just those related to SBD or fencing. - Recommendation: Please scope the dynamic discovery strictly to properties relevant to the SBD module. For instance, filter the dynamically discovered list to only include properties starting with
stonith-orfencing-, or pass a targeted prefix list to the utility.
2. Unsafe Deletion of Properties Without Replacements
In utils.py, DeprecatedTermTranslator.fix() automatically deletes properties that have no replacement (res.new_term is None):
if res.using_deprecated and res.deprecated_configured:
# ...
else:
delete_property(res.deprecated_term)- The Risk: Automatically deleting a configured property just because it is marked deprecated (without a replacement) is highly dangerous. An administrator may rely on that legacy property for specific behavior.
- Recommendation: If a property has no replacement, the
--fixcommand should not delete it. It is perfectly fine to log a warning during the check phase, but destructive actions without a clear migration path must be avoided to prevent breaking the cluster.
API Design & Maintainability
3. The direct Flag in get_property / set_property
Introducing direct=True to bypass the auto-translation logic solves the infinite recursion bug, but using a boolean flag to turn off core business logic is a code smell. Since most of the codebase expects these functions to be "smart" (auto-translating), we shouldn't clutter the signature.
- Recommendation: Instead of a
directflag, extract the core I/O logic into explicit "raw" or "dumb" functions (e.g.,_get_raw_propertyand_set_raw_property). The migration code inDeprecatedTermTranslator.fix()can safely call these raw functions directly. The publicget_property/set_propertyfunctions can remain as "smart" wrappers that handle translation and then call the raw functions.
4. Predictability of RAInfo.get_all_params_dict()
The boolean flags in def get_all_params_dict(self, deprecated=False, replaced_with=False) make the return type unpredictable.
- The Issue: Depending on the flags, it either returns
dict[str, dict](full parameter metadata) ordict[str, str|None](mapping a name to its replacement). Furthermore, ifdeprecated=Falseandreplaced_with=True, thereplaced_withflag is silently ignored. This breaks type hinting and readability. - Recommendation: Remove the boolean flags and split this into explicit, single-purpose properties/methods that return consistent types. For example:
get_active_params(self) -> dictget_deprecated_params(self) -> dictget_deprecated_mapping(self) -> dict[str, str|None]
5. Missing Null-Check on Value Migration
In DeprecatedTermTranslator.fix():
elif res.new_term:
value = get_property(res.deprecated_term, get_default=False, direct=True)
set_property(res.new_term, value, direct=True)- Recommendation: If
get_propertyreturnsNone(e.g., deleted concurrently),set_propertywill literally set the value to the string"None". Please wrap this in a quick null-check:if value is not None:before setting the new property.
Overall, the foundation of this PR is very strong. Addressing these scope and API design issues will make this a robust addition to the codebase. Let me know if you have any questions!
fc1e727 to
ef7ea37
Compare
Changed items 3, 4, and 5. |
c15b05f to
dbb7ef4
Compare
|
b6f34ed to
5926dbd
Compare
- Add deprecated-property check and fix item to SBDConfigChecker - Return boolean check status from DeprecatedTermTranslator - Add quiet-aware warnings for deprecated properties - Add direct get/set mode for migration without implicit translation - Move deprecated values to replacement properties during fix - Preserve default deprecated-alias cleanup in set_property - Cover translator and SBD deprecated-property behavior with unit tests
- Add active parameter metadata helper - Add deprecated parameter metadata helper - Add deprecated replacement mapping helper - Keep completion callers on active parameters - Update deprecated-property translation caller
SBD validation and repair should discover configured deprecated properties from Pacemaker metadata instead of relying on a static list. This keeps the SBD health flow aligned with the properties that are actually present in the cluster. - Add configured deprecated-property discovery - Use metadata-driven SBD checks and fixes - Add raw property helpers for migration I/O - Skip migration when the old value is gone - Keep deprecated terms without replacements - Treat no-replacement warnings as successful checks - Update unit and feature tests for migration
5926dbd to
55991e2
Compare
Description
This PR updates crmsh to use Pacemaker replacement cluster-property names by default and adds deprecated-property handling to the SBD health check/fix flow.
It reverts bootstrap-side use of deprecated
stonith-*names, discovers configured deprecated cluster properties from Pacemaker metadata, warns when deprecated properties are still present, and migrates or removes them duringcrm cluster health sbd --fix.Changes
fencing-*properties in bootstrap, SBD, qdevice, crash-test, UI, feature tests, and unit tests instead of deprecatedstonith-*names.SBDConfigChecker.Fix policy for deprecated properties
utils.DeprecatedTermTranslator.fix()applies this policy when the deprecated term is configured and the running cluster uses deprecated properties:Deprecated terms without a replacement are kept unchanged.
Notes
get_property()andset_property()remain the translated public wrappers._get_raw_property()and_set_raw_property()are used where the exact property name must be addressed during migration.