non zero exit codes for classes scripts

Martin Krämer mk.maddin at gmail.com
Fri Nov 1 11:03:58 CET 2019


Hi All,

after using this procedure some days I found some "bad" side effects.
The most critical one for me was:
FAI is killed and nobody knows that there is a device / server that has
failed with installation.
(This of course happens mainly if you are using FAI in an automated
environment without somebody starting FAI manually)

After some thinking I came across a better (and more FAI fashion) solution
which I of course want to share:

if any of these invalid class combinations is defined my scripts checks for
this and sets a new class:
ERRORCLASS

This class contains a single hook which skips all other tasks except the
ones required for logging and correct FAI working.
Based on this no bad action is performed during installation and I still
have fully functional logging/reporting process.
This is how the hook (action.ERRORCLASS.sh) looks like:































*#! /bin/bash# version: 2019.11.01# author: Martin Kraemer,
mk.maddin at gmail.com <mk.maddin at gmail.com># description: skip all tasks that
change the system - keep only logging etc.##--write an error message for
logging>&2 echo "$0: error: error within class configuration"#skiptask
confdir#skiptask setup#skiptask defclass#skiptask defvar#skiptsk
actionskiptask sysinfoskiptask inventory#skiptask install#skiptask
dirinstall#skiptask softupdateskiptask partitionskiptask mountdisksskiptask
extrbaseskiptask debconfskiptask repositoryskiptask updatebaseskiptask
instsoftskiptask configureskiptask tests#skiptask finish#skiptask
chboot#skiptask savelog#skiptask faiend*



Am Sa., 26. Okt. 2019 um 22:02 Uhr schrieb Martin Krämer <
mk.maddin at gmail.com>:

> Hi Thomas,
>
> Thanks for your Investigation.
> Yes - I was not able to find any related changes, too.
>
> Unfortunately as you already expected task_error does not end the full
> process tree - only fai-class.
> Never the less it helped me to find a good workaround which I use as
> follows:
>
> >&2 echo "error: my critical message"
> (kill -9 $PPID &)
> task_error 123
>
> Kind Regards
>
> Martin Krämer
>
> > On 26. Oct 2019, at 19:36, Thomas Lange <lange at informatik.uni-koeln.de>
> wrote:
> >
> > Hi Martin,
> >
> > I can find no change that causes a change in the behaviour for that
> > between 5.8.1 and the newest FAI version. As you pointed out an "exit X"
> > in a .sh script causes fai-class to stop defining more classes. You
> > can try to set an error code inside a .sh file by using a call to
> > task_error xxx. I'm not sure if this will work, since fai-class runs in a
> > subprocess.
> > After looking into the code it seems that fai-class almost always ends
> > with exit 0.
> >
> > --
> > regards Thomas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-koeln.de/pipermail/linux-fai/attachments/20191101/953d564b/attachment.html>


More information about the linux-fai mailing list