Skip to content

Commit

Permalink
Merge pull request #62448 from asomers/feature@
Browse files Browse the repository at this point in the history
zpool.present: correctly handle "feature@" properties
  • Loading branch information
Megan Wilhite authored Oct 12, 2022
2 parents 7957dc1 + 7c80756 commit a808930
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog/62390.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the "zpool.present" state when enabling zpool features that are already active.
9 changes: 8 additions & 1 deletion salt/states/zpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions tests/pytests/unit/states/test_zpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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)
Expand All @@ -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"),
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit a808930

Please sign in to comment.