Unverified Commit da43acd6 authored by r-vdp's avatar r-vdp
Browse files

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".
parent ea3ca97b
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -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(