Skip to content

Commit 5541be3

Browse files
committed
fix: handle explicit False for bootable and revertable parameters
Fix boolean parameter checking to distinguish between explicit False and unset (None) values. Previously, truthy checks treated False the same as None, causing silent conflicts when: - Global parameter set to False - Set-level parameter set to True The global False was silently ignored instead of raising a conflict error. Changes: - Use `module_args.get("param") is not None` instead of `if module_args["param"]:` - Applies to both snapshot_lvm_bootable and snapshot_lvm_revertable - Fixed in snapmgr.py (conflict detection) and validate.py (parameter propagation) This ensures ERROR_BOOTABLE_CONFLICT and ERROR_REVERTABLE_CONFLICT are correctly raised for all conflicting configurations, not just when the global value is True. Signed-off-by: Todd Gill <tgill@redhat.com>
1 parent 8162396 commit 5541be3

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

module_utils/snapshot_lsr/snapmgr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def mgr_snapshot_cmd(module, module_args, snapset_json):
230230
volume_list = snapset_json["volumes"]
231231

232232
# Bootable global variable is set
233-
if module_args["snapshot_lvm_bootable"]:
233+
if module_args.get("snapshot_lvm_bootable") is not None:
234234
bootable = module_args["snapshot_lvm_bootable"]
235235

236236
# Global is not set, check the snapset
@@ -252,7 +252,7 @@ def mgr_snapshot_cmd(module, module_args, snapset_json):
252252
}
253253

254254
# Revertable global variable is set
255-
if module_args["snapshot_lvm_revertable"]:
255+
if module_args.get("snapshot_lvm_revertable") is not None:
256256
revertable = module_args["snapshot_lvm_revertable"]
257257

258258
# Global is not set, check the snapset

module_utils/snapshot_lsr/validate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def get_json_from_args(module, module_args, vg_include):
3333
if module_args["snapshot_lvm_snapset_name"]:
3434
args_dict["name"] = module_args["snapshot_lvm_snapset_name"]
3535

36-
if module_args["snapshot_lvm_bootable"]:
36+
if module_args.get("snapshot_lvm_bootable") is not None:
3737
args_dict["bootable"] = module_args["snapshot_lvm_bootable"]
3838

39-
if module_args["snapshot_lvm_revertable"]:
39+
if module_args.get("snapshot_lvm_revertable") is not None:
4040
args_dict["revertable"] = module_args["snapshot_lvm_revertable"]
4141

4242
for vg, lv_list in vgs_lvs_iterator(
@@ -341,10 +341,10 @@ def validate_snapset_json(cmd, module_args, verify_only):
341341

342342
snapset_dict = module_args["snapshot_lvm_set"]
343343

344-
if module_args["snapshot_lvm_bootable"]:
344+
if module_args.get("snapshot_lvm_bootable") is not None:
345345
snapset_dict["snapshot_lvm_bootable"] = module_args["snapshot_lvm_bootable"]
346346

347-
if module_args["snapshot_lvm_revertable"]:
347+
if module_args.get("snapshot_lvm_revertable") is not None:
348348
snapset_dict["snapshot_lvm_revertable"] = module_args["snapshot_lvm_revertable"]
349349

350350
if cmd == SnapshotCommand.SNAPSHOT:

0 commit comments

Comments
 (0)