zfs: mark change correctly when updating properties whose current value differs, even if they already have a non-default value (Fixes #11019) #11172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Fixes #11019
Fix incorrect
changedreporting in thezfsmodule when updating ZFS properties usingextra_zfs_properties.Previously, if a property already had a non-default value (e.g.
SOURCE=local), applying a new value viaextra_zfs_propertieswould runzfs setcorrectly, but the module would still return:changed: falseISSUE TYPE
COMPONENT NAME
zfs
ADDITIONAL INFORMATION
Root cause
Previously, the module used:
But
get_property()always callszfs getagain, so at that point it reads the updated value, not the original one, and!=is always false for a successful change. Storing previous_values fixes this.Check mode behaviour is unchanged: in check mode,
set_property()just togglesself.changed = Trueand returns without running any command, and we still returndiffearly.Testing Done / Evidence
Manual functional validation on a real ZFS dataset with both:
changed: falsechanged: true✔️changed: false✔️You can see the exact output below:
Dataset compression:
Ansible output,
changed: true:Dataset compression correctly changed to
lz4:Second Ansible run output,
changed: false: