mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 01:30:20 +00:00
zpool.present: correctly handle "feature@" properties
Optional ZFS pool features can have three states: disabled, enabled, and active. Enabled means that ZFS will use them if it needs them, but they haven't changed the on-disk format yet, so they can still be switched off. But active features have already changed the on-disk format, so they can't be switched off. Disabled features may not be used. When enabling such a feature via the zpool.present state, treat "active" as identical to "enabled". Fixes #62390
This commit is contained in:
parent
4e1bbec71d
commit
7c80756044
3 changed files with 16 additions and 4 deletions
1
changelog/62390.fixed
Normal file
1
changelog/62390.fixed
Normal file
|
@ -0,0 +1 @@
|
|||
Fix the "zpool.present" state when enabling zpool features that are already active.
|
|
@ -319,7 +319,14 @@ def present(
|
|||
continue
|
||||
|
||||
# compare current and wanted value
|
||||
if properties_current[prop] != properties[prop]:
|
||||
# Enabled "feature@" properties may report either "enabled" or
|
||||
# "active", depending on whether they're currently in-use.
|
||||
if prop.startswith("feature@") and properties_current[prop] == "active":
|
||||
effective_property = "enabled"
|
||||
else:
|
||||
effective_property = properties_current[prop]
|
||||
|
||||
if effective_property != properties[prop]:
|
||||
properties_update.append(prop)
|
||||
|
||||
# update pool properties
|
||||
|
|
|
@ -340,7 +340,7 @@ def test_present_update_success(utils_patch):
|
|||
"name": "myzpool",
|
||||
"result": True,
|
||||
"comment": "properties updated",
|
||||
"changes": {"myzpool": {"autoexpand": False}},
|
||||
"changes": {"myzpool": {"autoexpand": False, "feature@bookmarks": "enabled"}},
|
||||
}
|
||||
|
||||
config = {
|
||||
|
@ -352,6 +352,8 @@ def test_present_update_success(utils_patch):
|
|||
]
|
||||
properties = {
|
||||
"autoexpand": False,
|
||||
"feature@hole_birth": "enabled",
|
||||
"feature@bookmarks": "enabled",
|
||||
}
|
||||
|
||||
mock_exists = MagicMock(return_value=True)
|
||||
|
@ -368,7 +370,7 @@ def test_present_update_success(utils_patch):
|
|||
("dedupditto", "0"),
|
||||
("dedupratio", "1.00x"),
|
||||
("autoexpand", True),
|
||||
("feature@bookmarks", "enabled"),
|
||||
("feature@bookmarks", "disabled"),
|
||||
("allocated", 115712),
|
||||
("guid", 1591906802560842214),
|
||||
("feature@large_blocks", "enabled"),
|
||||
|
@ -421,7 +423,7 @@ def test_present_update_success(utils_patch):
|
|||
|
||||
def test_present_update_nochange_success(utils_patch):
|
||||
"""
|
||||
Test zpool present with non existing pool
|
||||
Test zpool present with an up-to-date pool
|
||||
"""
|
||||
config = {
|
||||
"import": False,
|
||||
|
@ -432,6 +434,8 @@ def test_present_update_nochange_success(utils_patch):
|
|||
]
|
||||
properties = {
|
||||
"autoexpand": True,
|
||||
"feature@hole_birth": "enabled",
|
||||
"feature@bookmarks": "enabled",
|
||||
}
|
||||
|
||||
mock_exists = MagicMock(return_value=True)
|
||||
|
|
Loading…
Add table
Reference in a new issue