[systemd-devel] [PATCH] bus-util: be more verbose if bus job failed because of start limit
Michal Sekletar
msekleta at redhat.com
Tue Mar 31 08:10:01 PDT 2015
Users might have hard time figuring out that they need to call systemctl
reset-failed, before they are allowed to start the service again, after service
ended up in failed state because start job rate limiting. Let's be nice and
print better error message.
https://bugzilla.redhat.com/show_bug.cgi?id=1016680
---
src/libsystemd/sd-bus/bus-util.c | 49 +++++++++++++++++++++++++++++++++++++---
1 file changed, 46 insertions(+), 3 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index dcad701..27217d9 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -30,6 +30,7 @@
#include "path-util.h"
#include "missing.h"
#include "set.h"
+#include "unit-name.h"
#include "sd-bus.h"
#include "bus-error.h"
@@ -1721,6 +1722,35 @@ static int bus_process_wait(sd_bus *bus) {
}
}
+static int bus_job_get_service_result(BusWaitForJobs *d, char **result) {
+ int r = 0;
+ _cleanup_free_ char *dbus_path = NULL, *p = NULL;
+
+ assert(d);
+ assert(d->result);
+ assert(d->name);
+ assert(result);
+
+ dbus_path = unit_dbus_path_from_name(d->name);
+ if (!dbus_path)
+ return -ENOMEM;
+
+ r = sd_bus_get_property_string(d->bus,
+ "org.freedesktop.systemd1",
+ dbus_path,
+ "org.freedesktop.systemd1.Service",
+ "Result",
+ NULL,
+ &p);
+ if (r < 0)
+ return r;
+
+ *result = p;
+ p = NULL;
+
+ return 0;
+}
+
static int check_wait_response(BusWaitForJobs *d, bool quiet) {
int r = 0;
@@ -1741,13 +1771,26 @@ static int check_wait_response(BusWaitForJobs *d, bool quiet) {
log_error("Operation on or unit type of %s not supported on this system.", strna(d->name));
else if (!streq(d->result, "done") && !streq(d->result, "skipped")) {
if (d->name) {
+ int q;
bool quotes;
+ _cleanup_free_ char *result = NULL;
quotes = chars_intersect(d->name, SHELL_NEED_QUOTES);
- log_error("Job for %s failed. See \"systemctl status %s%s%s\" and \"journalctl -xe\" for details.",
- d->name,
- quotes ? "'" : "", d->name, quotes ? "'" : "");
+ q = bus_job_get_service_result(d, &result);
+ if (q < 0)
+ log_debug_errno(q, "Failed to get Result property of service %s: %m", d->name);
+
+ if (streq_ptr(result, "start-limit"))
+ log_error("Starting %s has been attempted too often too quickly, the repeated start of the unit has been refused.\n"
+ "To force a start please invoke \"systemctl reset-failed %s%s%s\" followed by \"systemctl start %s%s%s\" again.",
+ d->name,
+ quotes ? "'" : "", d->name, quotes ? "'" : "",
+ quotes ? "'" : "", d->name, quotes ? "'" : "");
+ else
+ log_error("Job for %s failed. See \"systemctl status %s%s%s\" and \"journalctl -xe\" for details.",
+ d->name,
+ quotes ? "'" : "", d->name, quotes ? "'" : "");
} else
log_error("Job failed. See \"journalctl -xe\" for details.");
}
--
2.3.4
More information about the systemd-devel
mailing list