switch-to-configuration-ng: Ignore removal of ExecReload

Adding or changing ExecReload now triggers a reload, but removing it
still triggered a restart. The running process is unaffected by the
removal and the new unit no longer has a reload command to invoke, so
treat it like the other ignored [Unit] keys and take no action.

Covers both "key removed from existing [Service]" and "[Service]
section removed that only contained ExecReload".
This commit is contained in:
r-vdp
2026-04-28 17:03:44 +02:00
parent ea3ca97b36
commit da43acd6e7
@@ -532,6 +532,13 @@ fn compare_units(current_unit: &UnitInfo, new_unit: &UnitInfo) -> UnitComparison
}
}
continue; // check the next section
} else if section_name == "Service"
&& section_val.len() == 1
&& section_val.contains_key("ExecReload")
{
// Dropping ExecReload does not affect the running process and the
// new unit can no longer be reloaded, so there is nothing to do.
continue;
} else {
return UnitComparison::UnequalNeedsRestart;
}
@@ -562,6 +569,11 @@ fn compare_units(current_unit: &UnitInfo, new_unit: &UnitInfo) -> UnitComparison
if section_name == "Unit" && unit_section_ignores.contains_key(ini_key.as_str()) {
continue;
}
// Dropping ExecReload does not affect the running process and the
// new unit can no longer be reloaded, so there is nothing to do.
if section_name == "Service" && ini_key == "ExecReload" {
continue;
}
return UnitComparison::UnequalNeedsRestart;
};
@@ -2710,6 +2722,33 @@ invalid
) == super::UnitComparison::UnequalNeedsReload
);
// ExecReload removed: running process is unaffected and the new
// unit cannot be reloaded, so no action is needed.
assert!(
super::compare_units(
&HashMap::from([(
"Service".to_string(),
HashMap::from([
("ExecStart".to_string(), vec!["x".to_string()]),
("ExecReload".to_string(), vec!["y".to_string()]),
])
)]),
&HashMap::from([(
"Service".to_string(),
HashMap::from([("ExecStart".to_string(), vec!["x".to_string()])])
)]),
) == super::UnitComparison::Equal
);
assert!(
super::compare_units(
&HashMap::from([(
"Service".to_string(),
HashMap::from([("ExecReload".to_string(), vec!["y".to_string()])])
)]),
&HashMap::from([]),
) == super::UnitComparison::Equal
);
// ExecReload added to an existing [Service] section
assert!(
super::compare_units(