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

2013-09-12 Thread Olivier Brunel
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

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-09-12 Thread Kay Sievers
On Thu, Sep 12, 2013 at 2:37 PM, Olivier Brunel j...@jjacky.com wrote:
 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).

Just put an empty file as /etc/machine-id, if you really cannot set it
up properly, systemd will mount a tmp file with a randome machine-id
there, and all should work.

It's not an optimal setup, you will have to deal with side-effects,
like if you have a writable /var and the journal will use the
machine-id as the directory name.

There is more than the journal that will fail, systemd just mandates a
working machine-id.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-09-12 Thread Lennart Poettering
On Thu, 12.09.13 14:37, Olivier Brunel (j...@jjacky.com) wrote:

 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) ?)

We probably should already refuse the boot from PID 1 if /etc/machine-id
cannot be set up, like we already do if /etc/os-release is not
found...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-09-12 Thread Lennart Poettering
On Thu, 12.09.13 14:37, Olivier Brunel (j...@jjacky.com) wrote:

 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) ?)

Applied. Thanks!

(I also added to the TODO list that we should refuse booting early on if
the machine id cannot be set up)

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel