[systemd-devel] [PATCH] journald: Log error when failed to get machine-id on start

Olivier Brunel jjk at jjacky.com
Thu Sep 12 05:37:30 PDT 2013


Can help since the journal requires /etc/machine-id to exists in order to start,
and will simply silently exit when it does not.
---
Not sure if the behavior is known/expected or a bug, but when e.g. booting a
system with a read-only rootfs where /etc/machine-id doesn't exist, the journal
would just silently fail (over & over) with no indication of why (even at debug
log_level), and regardless of the Storage option (i.e. even with Storage=none).

Again, this might be expected, so this just adds a log message to clue you in on
why it doesn't start. (Might also be a good idea to mention this requirement in
systemd-journald(8) ?)

 src/journal/journald-server.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 9daeb6e..ba211b3 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -897,8 +897,10 @@ static int system_journal_open(Server *s) {
         char ids[33];
 
         r = sd_id128_get_machine(&machine);
-        if (r < 0)
+        if (r < 0) {
+                log_error("Failed to get machine id: %s", strerror(-r));
                 return r;
+        }
 
         sd_id128_to_string(machine, ids);
 
@@ -1000,10 +1002,8 @@ int server_flush_to_var(Server *s) {
         log_debug("Flushing to /var...");
 
         r = sd_id128_get_machine(&machine);
-        if (r < 0) {
-                log_error("Failed to get machine id: %s", strerror(-r));
+        if (r < 0)
                 return r;
-        }
 
         r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY);
         if (r < 0) {
-- 
1.8.4



More information about the systemd-devel mailing list