#3207 Issue open: Recreating initrd failure shows misleading message when not in debug mode

Labels: enhancement, minor bug

jsmeix opened issue at 2024-04-10 13:38:

See
https://github.com/rear/rear/pull/3206
therein in particular (excerpts):
https://github.com/rear/rear/pull/3206#issuecomment-2047273428

dracut not showing errors in the ReaR log

and
https://github.com/rear/rear/pull/3206#issuecomment-2047547566

about the dracut not showing errors problem I figured out what is going on:

In normal (non-debug) ReaR mode stderr goes to $STDOUT_STDERR_FILE
and the Error function can then quote from that.
However, our code surrounding dracut doesn't use the Error function
but instead only does a LogPrint suggesting to look into
the $RUNTIME_LOGFILE, and that is the reason that the
logfile doesn't contain useful infos.

How should we solve this?
Maybe extract the "pull last lines from stderr" into a function
that can then be used? Or add a LogPrintError function
that will also show last errors if exist?

... I think it is important to keep in mind and fix
so that users can get an info about the problem
for errors without running ReaR again in debug mode.

jsmeix commented at 2024-04-10 14:19:

I will have to think about it...

We already have a LogPrintError function which is
currently used differently, see its description in
lib/_input-output-functions.sh

For specific usage examples see for example
finalize/default/060_compare_files.sh

LogPrintError "Restored files in $TARGET_FS_ROOT do not fully match the recreated system"
LogPrintError "(files in the backup are not same as when the ReaR rescue/recovery system was made)"
...
LogPrintError "$( sed -e "s|^/|$TARGET_FS_ROOT/|" -e 's/^/  /' <<< "$md5sum_stdout" )"
LogPrintError "Manually check if those changed files cause issues in your recreated system"

and also
usr/share/rear/prep/PXE/default/010_PXE_check.sh
usr/share/rear/lib/opaladmin-workflow.sh
usr/share/rear/lib/_input-output-functions.sh
usr/share/rear/lib/opal-functions.sh
usr/share/rear/build/default/990_verify_rootfs.sh
usr/share/rear/restore/FDRUPSTREAM/default/260_copy_log_and_report.sh
that use several subsequent LogPrintError calls
where ReaR log file output is unwanted.
In general the current LogPrintError function
is not meant to provide ReaR log file output.
In contrast the Error function can provide ReaR log file output
because the Error function is the last function that is called
so ReaR log file output will be shown only once.

My current offhanded guess is that a separated function
(extract the 'pull last lines from stderr' into a function)
to show ReaR log file output could be a possible solution
so that we have control when ReaR log file output is shown.

The current # Extract lines ... code
in the Error function depends on that this happens
within the [Bug]*Error function so some adaptions
and enhancements are needed to make that code a
generic LastSourcedScriptStdoutStderr function.


[Export of Github issue for rear/rear.]