ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
Harald Hoyer d4ee25
From a38c3d5d4e94c7e11db1ca22126bb11c6b029886 Mon Sep 17 00:00:00 2001
Harald Hoyer d4ee25
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Harald Hoyer d4ee25
Date: Sun, 15 Sep 2013 12:15:38 -0400
Harald Hoyer d4ee25
Subject: [PATCH] transaction.c: do not point users to logs when unit not found
Harald Hoyer d4ee25
Harald Hoyer d4ee25
The logs are unlikely to contain any useful information in this case.
Harald Hoyer d4ee25
Harald Hoyer d4ee25
Also, change "walked on cycle path" to "found dependency on", which
Harald Hoyer d4ee25
is less technical and indicates the direction. With the old message,
Harald Hoyer d4ee25
I was never sure if prior units depended on later ones, or vice versa.
Harald Hoyer d4ee25
Harald Hoyer d4ee25
https://bugzilla.redhat.com/show_bug.cgi?id=996133
Harald Hoyer d4ee25
https://bugzilla.redhat.com/show_bug.cgi?id=997082
Harald Hoyer d4ee25
---
Harald Hoyer d4ee25
 src/core/transaction.c | 14 +++++++++++---
Harald Hoyer d4ee25
 1 file changed, 11 insertions(+), 3 deletions(-)
Harald Hoyer d4ee25
Harald Hoyer d4ee25
diff --git a/src/core/transaction.c b/src/core/transaction.c
Harald Hoyer d4ee25
index 27efef7..203070f 100644
Harald Hoyer d4ee25
--- a/src/core/transaction.c
Harald Hoyer d4ee25
+++ b/src/core/transaction.c
Harald Hoyer d4ee25
@@ -344,7 +344,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
Harald Hoyer d4ee25
         assert(!j->transaction_prev);
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
         /* Does a recursive sweep through the ordering graph, looking
Harald Hoyer d4ee25
-         * for a cycle. If we find cycle we try to break it. */
Harald Hoyer d4ee25
+         * for a cycle. If we find a cycle we try to break it. */
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
         /* Have we seen this before? */
Harald Hoyer d4ee25
         if (j->generation == generation) {
Harald Hoyer d4ee25
@@ -371,7 +371,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
                         /* logging for j not k here here to provide consistent narrative */
Harald Hoyer d4ee25
                         log_info_unit(j->unit->id,
Harald Hoyer d4ee25
-                                      "Walked on cycle path to %s/%s",
Harald Hoyer d4ee25
+                                      "Found dependency on %s/%s",
Harald Hoyer d4ee25
                                       k->unit->id, job_type_to_string(k->type));
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
                         if (!delete &&
Harald Hoyer d4ee25
@@ -860,7 +860,7 @@ int transaction_add_job_and_dependencies(
Harald Hoyer d4ee25
                 return -EINVAL;
Harald Hoyer d4ee25
         }
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
-        if (type != JOB_STOP && (unit->load_state == UNIT_ERROR || unit->load_state == UNIT_NOT_FOUND)) {
Harald Hoyer d4ee25
+        if (type != JOB_STOP && unit->load_state == UNIT_ERROR) {
Harald Hoyer d4ee25
                 dbus_set_error(e, BUS_ERROR_LOAD_FAILED,
Harald Hoyer d4ee25
                                "Unit %s failed to load: %s. "
Harald Hoyer d4ee25
                                "See system logs and 'systemctl status %s' for details.",
Harald Hoyer d4ee25
@@ -870,6 +870,14 @@ int transaction_add_job_and_dependencies(
Harald Hoyer d4ee25
                 return -EINVAL;
Harald Hoyer d4ee25
         }
Harald Hoyer d4ee25
 
Harald Hoyer d4ee25
+        if (type != JOB_STOP && unit->load_state == UNIT_NOT_FOUND) {
Harald Hoyer d4ee25
+                dbus_set_error(e, BUS_ERROR_LOAD_FAILED,
Harald Hoyer d4ee25
+                               "Unit %s failed to load: %s.",
Harald Hoyer d4ee25
+                               unit->id,
Harald Hoyer d4ee25
+                               strerror(-unit->load_error));
Harald Hoyer d4ee25
+                return -EINVAL;
Harald Hoyer d4ee25
+        }
Harald Hoyer d4ee25
+
Harald Hoyer d4ee25
         if (type != JOB_STOP && unit->load_state == UNIT_MASKED) {
Harald Hoyer d4ee25
                 dbus_set_error(e, BUS_ERROR_MASKED, "Unit %s is masked.", unit->id);
Harald Hoyer d4ee25
                 return -EADDRNOTAVAIL;