]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
job: when a job was skipped due to a failed condition, log about it
authorLennart Poettering <lennart@poettering.net>
Wed, 14 Nov 2018 10:08:16 +0000 (11:08 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 16 Nov 2018 14:30:36 +0000 (15:30 +0100)
Previously we'd neither show console status output nor log output. Let's
fix that, and still log something.

src/core/job.c

index fc3d8d8308a9f536a8e2d4aaef5c1fa6e1c26699..ec1113f2dd3f3e9d0e3fc8802373f090b3362599 100644 (file)
@@ -822,6 +822,10 @@ static void job_print_done_status_message(Unit *u, JobType t, JobResult result)
         if (t == JOB_RELOAD)
                 return;
 
+        /* No message if the job did not actually do anything due to failed condition. */
+        if (t == JOB_START && result == JOB_DONE && !u->condition_result)
+                return;
+
         if (!job_print_done_status_messages[result].word)
                 return;
 
@@ -877,6 +881,20 @@ static void job_log_done_status_message(Unit *u, uint32_t job_id, JobType t, Job
         if (log_on_console() && job_print_done_status_messages[result].word)
                 return;
 
+        /* Show condition check message if the job did not actually do anything due to failed condition. */
+        if (t == JOB_START && result == JOB_DONE && !u->condition_result) {
+                log_struct(LOG_INFO,
+                           "MESSAGE=Condition check resulted in %s being skipped.", unit_description(u),
+                           "JOB_ID=%" PRIu32, job_id,
+                           "JOB_TYPE=%s", job_type_to_string(t),
+                           "JOB_RESULT=%s", job_result_to_string(result),
+                           LOG_UNIT_ID(u),
+                           LOG_UNIT_INVOCATION_ID(u),
+                           "MESSAGE_ID=" SD_MESSAGE_UNIT_STARTED_STR);
+
+                return;
+        }
+
         format = job_get_done_status_message_format(u, t, result);
         if (!format)
                 return;
@@ -931,10 +949,6 @@ static void job_log_done_status_message(Unit *u, uint32_t job_id, JobType t, Job
 static void job_emit_done_status_message(Unit *u, uint32_t job_id, JobType t, JobResult result) {
         assert(u);
 
-        /* No message if the job did not actually do anything due to failed condition. */
-        if (t == JOB_START && result == JOB_DONE && !u->condition_result)
-                return;
-
         job_log_done_status_message(u, job_id, t, result);
         job_print_done_status_message(u, t, result);
 }