#3296 Issue closed: Setting ISO_MKISOFS_BIN default parameter in site or local.conf results in recovery error

Labels: documentation, support / question, fixed / solved / done

damm620 opened issue at 2024-07-23 13:23:

  • ReaR version ("/usr/sbin/rear -V"):
    Relax-and-Recover 2.7

  • OS version ("cat /etc/os-release" or "lsb_release -a" or "cat /etc/rear/os.conf"):
    CENTOS/9.0

  • ReaR configuration files ("cat /etc/rear/site.conf" and/or "cat /etc/rear/local.conf"):

cat /etc/rear/site.conf
OUTPUT=ISO               # Creates an ISO file - other e.g. RAMDISK
BACKUP=TSM               # Backup/Restore method - other e.g. rsync
COPY_AS_IS_TSM=( "/etc/adsm/ /opt/tivoli/tsm/client /usr/local/ibm/gsk8* /SZIR/data/inclexcl2 /SZIR/data/dsm.sys /SZIR/data/dsm.opt" )  # Files which should be in the ISO
# Skip language files to reduce the ISO size
COPY_AS_IS_EXCLUDE_TSM=( "/opt/tivoli/tsm/client/ba/bin/ZH_CN/*" "/opt/tivoli/tsm/client/ba/bin/ZH_TW/*" "/opt/tivoli/tsm/client/ba/bin/IT_IT/*" "/opt/tivoli/tsm/client/ba/bin/CS_CZ/*" "/opt/tivoli/tsm/client/ba/bin/ES_ES*" "/opt/tivoli/tsm/client/ba/bin/FR_FR/*" "/opt/tivoli/tsm/client/ba/bin/HU_HU/*" "/opt/tivoli/tsm/client/ba/bin/KO_KR/*" "/opt/tivoli/tsm/client/ba/bin/PL_PL/*" "/opt/tivoli/tsm/client/ba/bin/PT_BR/*" "/opt/tivoli/tsm/client/ba/bin/JA_JP/*" "/opt/tivoli/tsm/client/ba/bin/RU_RU/*" "/opt/tivoli/tsm/client/ba/bin/plugins/*" "/opt/tivoli/tsm/client/api/bin64/CS_CZ*" "/opt/tivoli/tsm/client/api/bin64/DE_DE/*" "/opt/tivoli/tsm/client/api/bin64/dsmenc" "/opt/tivoli/tsm/client/api/bin64/dsm.opt.smp" "/opt/tivoli/tsm/client/api/bin64/dsm.sys.smp" "/opt/tivoli/tsm/client/api/bin64/dsmtca" "/opt/tivoli/tsm/client/api/bin64/EN_US" "/opt/tivoli/tsm/client/api/bin64/ES_ES" "/opt/tivoli/tsm/client/api/bin64/FR_FR" "/opt/tivoli/tsm/client/api/bin64/HU_HU" "/opt/tivoli/tsm/client/api/bin64/IT_IT" "/opt/tivoli/tsm/client/api/bin64/JA_JP" "/opt/tivoli/tsm/client/api/bin64/KO_KR" "/opt/tivoli/tsm/client/api/bin64/PL_PL" "/opt/tivoli/tsm/client/api/bin64/PT_BR" "/opt/tivoli/tsm/client/api/bin64/RU_RU" "/opt/tivoli/tsm/client/api/bin64/sample" "/opt/tivoli/tsm/client/api/bin64/ZH_CN" "/opt/tivoli/tsm/client/api/bin64/ZH_TW" )
CHECK_CONFIG_FILES=( '/etc/adsm/' '/etc/drbd/' '/etc/drbd.conf' '/etc/lvm/lvm.conf' '/etc/multipath.conf' '/etc/rear/' '/etc/udev/udev.conf' '/opt/tivoli/tsm/client/ba/bin/dsmc' )
PROGS_TSM=(dsmc)
PROGS=( ${PROGS[@]} "vconfig vi vim" )
NON_FATAL_BINARIES_WITH_MISSING_LIBRARY=("/opt/tivoli/tsm/client/*|/usr/local/ibm/gsk8_64/bin/")
GRUB_RESCUE=y
AUTOEXCLUDE_MULTIPATH=y  # Default Wert=y - multipath devices are not created/saved. Which is usually not necessary
                         # If these must be restored nevertheless e.g. "rm -rf /". The restore must be performed manually afterwards
TSM_RESULT_SAVE=n        # Don't save ISO in TSM
KEEP_BUILD_DIR=n         # Remove build directory (dir in /tmp) in any case to prevent full filesystem
USER_INPUT_TIMEOUT=900   # Increase timeout for user input from 5 to 15 minutes
USE_DHCLIENT="n"
ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )"

cat /etc/rear/local.conf
# Default is to create Relax-and-Recover rescue media as ISO image
# set OUTPUT to change that
# set BACKUP to activate an automated (backup and) restore of your data
# Possible configuration values can be found in /usr/share/rear/conf/default.conf
#
# This file (local.conf) is intended for manual configuration. For configuration
# through packages and other automated means we recommend creating a new
# file named site.conf next to this file and to leave the local.conf as it is.
# Our packages will never ship with a site.conf.
  • Hardware vendor/product (PC or PowerNV BareMetal or ARM) or VM (KVM guest or PowerVM LPAR):
    VMware

  • System architecture (x86 compatible or PPC64/PPC64LE or what exact ARM device):
    x86

  • Firmware (BIOS or UEFI or Open Firmware) and bootloader (GRUB or ELILO or Petitboot):
    BIOS

  • Storage (local disk or SSD) and/or SAN (FC or iSCSI or FCoE) and/or multipath (DM or NVMe):
    local

  • Storage layout ("lsblk -ipo NAME,KNAME,PKNAME,TRAN,TYPE,FSTYPE,LABEL,SIZE,MOUNTPOINT"):

NAME                                                      KNAME      PKNAME    TRAN TYPE FSTYPE      LABEL  SIZE MOUNTPOINT
/dev/sda                                                  /dev/sda                  disk                     80G
|-/dev/sda1                                               /dev/sda1  /dev/sda       part xfs                  1G /boot
`-/dev/sda2                                               /dev/sda2  /dev/sda       part LVM2_member         79G
  |-/dev/mapper/vg00-root                                 /dev/dm-0  /dev/sda2      lvm  xfs                  2G /
  |-/dev/mapper/vg00-swap                                 /dev/dm-1  /dev/sda2      lvm  swap                 4G [SWAP]
  |-/dev/mapper/vg00-usr                                  /dev/dm-2  /dev/sda2      lvm  xfs                  4G /usr
  [...]
/dev/sr0
  • Description of the issue (ideally so that others can reproduce it):

The default of the parameter ISO_MKISOFS_BIN is ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )".
This configuration is maintained in the /usr/share/rear/conf/default.conf.

We wanted to make sure, that the default is always this way and we set the parameter in the /etc/rear/site.conf.
This resulted in the following error:

RESCUE SERVERNAME:~ # grep ISO_MKISOFS_BIN /etc/rear/site.conf
ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )"

RESCUE SERVERNAME:~ # rear -v recover
Relax-and-Recover 2.7 / Git
Running rear recover (PID 584 date 2024-07-23 15:17:36)
Using log file: /var/log/rear/rear-SERVERNAME.log
ERROR: Failed to Source /etc/rear/site.conf
Use debug mode '-d' for some debug messages or debugscript mode '-D' for full debug messages with 'set -x' output
Aborting due to an error, check /var/log/rear/rear-SERVERNAME.log for details
Exiting rear recover (PID 584) and its descendant processes ...
Running exit tasks
Terminated

RESCUE SERVERNAME:~ # set -x ;rear -D recover
+ rear -D recover
Relax-and-Recover 2.7 / Git
Running rear recover (PID 1076 date 2024-07-23 15:17:56)
Command line options: /bin/rear -D recover
Using log file: /var/log/rear/rear-SERVERNAME.log
Using build area: /var/tmp/rear.HjRaTy69R1AUZ47
ERROR: Failed to Source /etc/rear/site.conf
Aborting due to an error, check /var/log/rear/rear-SERVERNAME.log for details
Exiting rear recover (PID 1076) and its descendant processes ...
Running exit tasks
Terminated

Setting this parameter in the /etc/rear/local.conf resulted in the (nearly) same error:

RESCUE SERVERNAME:~ # grep ISO_MKISOFS_BIN /etc/rear/local.conf
+ grep ISO_MKISOFS_BIN /etc/rear/local.conf
ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )"
RESCUE SERVERNAME:~ # set -x ;rear -D recover
+ set -x
+ rear -D recover
Relax-and-Recover 2.7 / Git
Running rear recover (PID 1366 date 2024-07-23 15:19:12)
Command line options: /bin/rear -D recover
Using log file: /var/log/rear/rear-SERVERNAME.log
Using build area: /var/tmp/rear.ykhOby3UkGnzfMH
ERROR: Failed to Source /etc/rear/local.conf
Aborting due to an error, check /var/log/rear/rear-SERVERNAME.log for details
Exiting rear recover (PID 1366) and its descendant processes ...
Running exit tasks
Terminated

Should it be this way? We just want to force the value of ISO_MKISOFS_BIN and do not want to alter the default.conf under /usr because it is bad practise and there are the site or local.conf for it right?

jsmeix commented at 2024-07-24 07:06:

@damm620
yes, it behaves as intended.

Reasoning:

In usr/sbin/rear there is

for config in site local rescue ; do
    if test -r "$CONFIG_DIR/$config.conf" ; then
        ...
        Source "$CONFIG_DIR/$config.conf" || Error "Failed to Source $CONFIG_DIR/$config.conf"
    fi
done

and the Source function in
usr/share/rear/lib/framework-functions.sh
does

function Source () {
    local source_file="$1"
    local source_return_code=0
    ...
    # The actual work (source the source file):
    # Do not error out here when 'source' fails (i.e. when 'source' returns a non-zero exit code)
    # because scripts usually return the exit code of their last command
    # cf. https://github.com/rear/rear/issues/1965#issuecomment-439330017
    # and in general ReaR should not error out in a (helper) function but instead
    # a function should return an error code so that its caller can decide what to do
    # cf. https://github.com/rear/rear/pull/1418#issuecomment-316004608
    source "$source_file"
    source_return_code=$?
    ...
    # Return the return value of the actual work (source the source file):
    return $source_return_code
}

Because

ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )"

is the last command in your /etc/rear/site.conf
it seems this command somehow fails in your case
so sourcing /etc/rear/site.conf exits with non-zero exit code.

I don't know why this command fails in your case
because for me it works both on command line

# ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )" && echo OK || echo FAIL
OK

# echo "'$ISO_MKISOFS_BIN'"
'/usr/bin/xorrisofs'

# ( set -x ; ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )" && echo OK || echo FAIL )
++ type -p xorrisofs
+ ISO_MKISOFS_BIN=/usr/bin/xorrisofs
+ echo OK
OK

and also as last command in my /etc/rear/local.conf

jsmeix commented at 2024-07-24 07:14:

Ah! - It seems now I see it:
You wrote

RESCUE SERVERNAME

so I assume it also works for you on your original system
but it fails (only when) inside the ReaR recovery system.

It fails inside the ReaR recovery system
because there is neither xorrisofs nor mkisofs
nor genisoimage inside the ReaR recovery system:

# usr/sbin/rear -D mkrescue
...
Using build area: /var/tmp/rear.yLl36HSECpPTpTb
...
Running exit tasks
To remove the build area you may use (with caution): rm -Rf --one-file-system /var/tmp/rear.yLl36HSECpPTpTb

# chroot /var/tmp/rear.yLl36HSECpPTpTb/rootfs

bash-4.4# ( set -x ; ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )" && echo OK || echo FAIL )
++ type -p xorrisofs
++ type -p mkisofs
++ type -p genisoimage
+ ISO_MKISOFS_BIN=
+ echo FAIL
FAIL

jsmeix commented at 2024-07-24 07:19:

In ReaR's recovery system /etc/rear-release is unique
(it does not exist otherwise) so you can use it to test
if you are inside the ReaR recovery system
for example like

test -e "/etc/rear-release" || ISO_MKISOFS_BIN="$( type -p xorrisofs || type -p mkisofs || type -p genisoimage )"

damm620 commented at 2024-07-24 07:22:

test -e "/etc/rear-release"

Thank you for your quick response!
You solution looks nice. I have to test that, but my workload is quite high. I will give a feedback as soon as I get it done.

jsmeix commented at 2024-07-24 07:37:

Via
https://github.com/rear/rear/commit/94016e7ad6939ce11e37b4d7bf5e889ee47f9daf
I enhanced the local.conf comment to explain that
one must ensure commands in configuration files
work always without errors regardless in which
environment those commands will be run,
in particular on the original system and
also within the ReaR recovery system.

jsmeix commented at 2024-07-24 07:59:

@damm620
to avoid this error exit you could move this command
up to an earlier line i.e. away from being the last command
because the exit code of the last command is what the
exit code of 'source' is.
Or alternatively add a 'true' command as last command.

The reason why we error out when 'source config_file'
results a non-zero exit code is mainly to detect
when things can not at all work in config files,
for example syntax errors.


[Export of Github issue for rear/rear.]