summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-11-30 17:03:57 -0800
committerRatan Gupta <ratagupt@linux.vnet.ibm.com>2019-01-18 02:22:18 +0000
commita5b1b0d04197dc7b11afd0358c51ffb2320afcd6 (patch)
treeb69c00e1e511eaaf04a19bc31ef4fcc091c211d8
parentcb500dc2b5def5773d693e88aa432e5f2ba5a585 (diff)
downloadphosphor-networkd-a5b1b0d04197dc7b11afd0358c51ffb2320afcd6.tar.gz
phosphor-networkd-a5b1b0d04197dc7b11afd0358c51ffb2320afcd6.zip
util: Reset Failed Before Restarting Service
If we don't reset the failed counter in systemd for a specific service like systemd-networkd, restarts won't always be issued as expected. If the service fails due to a bad configuration, future changes that would normally put it in a valid state will be unable to restart it since it hit the reset threshold for the given time window. Tested: Built and ran on a zaius for testing. Issuing bad network configuration changes over ipmi no longer prevents future changes from fixing systemd-networkd. Change-Id: I646309001a257b12e2df006d8c420c93c5c0bca8 Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--network_manager.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/network_manager.cpp b/network_manager.cpp
index bd1244d..c4ab0da 100644
--- a/network_manager.cpp
+++ b/network_manager.cpp
@@ -217,6 +217,21 @@ void Manager::restartSystemdUnit(const std::string& unit)
try
{
auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "ResetFailedUnit");
+ method.append(unit);
+ bus.call_noreply(method);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ log<level::ERR>("Failed to reset failed unit",
+ entry("UNIT=%s", unit.c_str()),
+ entry("ERR=%s", ex.what()));
+ elog<InternalFailure>();
+ }
+
+ try
+ {
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
SYSTEMD_INTERFACE, "RestartUnit");
method.append(unit.c_str(), "replace");
bus.call_noreply(method);
OpenPOWER on IntegriCloud