#2839 PR merged
: Pass -y to lvcreate instead of piping the output of yes¶
Labels: enhancement
, cleanup
, fixed / solved / done
pcahyna opened issue at 2022-07-14 14:04:¶
Pull Request Details:¶
-
Type: Cleanup
-
Impact: Low
-
Reference to related issue (URL): #2834 #2827
-
How was this pull request tested?
In the same way as #2834 -
Brief description of the changes in this pull request:
Revert "Use fail-safe 'yes' pipe for "lvm lvcreate"" - PR #2827 and pass-y
tolvcreate
to stop asking for input instead.
The -y
option is much simpler and less error-prone than a 'yes' pipe
(no error termination because of SIGPIPE, for instance). But we lose
support for SLES11, where lvcreate
does not know the -y
option.
yes
remains among REQUIRED_PROGS
, it can be useful in the rescue
system. (It could be theoretically moved to PROGS, because it is not
required anymore. This could be done separately if really desired, but
for now we prefer to keep it in REQUIRED_PROGS, sooner or later
something will start requiring it.) See the discussion in
https://github.com/rear/rear/pull/2834
.
pcahyna commented at 2022-07-15 08:33:¶
And if
lvm lvcreate -y ...
fails (e.g. because old lvm does not support '-y') the user gets failure messages so things do not go wrong silently.
I am afraid they won't see the error from the lvm
command itself,
because the output of commands is nowadays hidden, isn't it? I guess
that the diskrestore.sh script may get some special handling...
jsmeix commented at 2022-07-15 10:27:¶
Exactly because users won't see errors from commands itself
such LogPrintError messages are crucial to not let it
appear to the user as if ReaR is failing silently.
When things fail with
Failed to create LVM volume 'VG/LV' with lvcreate -y ...
Also failed to create LVM volume 'VG/LV' with lvcreate -y ..."
on the user's terminal where he launched "rear recover"
it should be sufficiently obvious for the user
where he could look for the reason
AND
it is sufficiently clear for us how to help him
(provided the user managed to show us his
terminal output or his "rear recover" log file).
jsmeix commented at 2022-07-15 10:29:¶
@pcahyna
I could test how it actually looks when it fails with SLES11.
jsmeix commented at 2022-07-18 09:10:¶
How it actually looks when it fails with SLES11:
In debugscript mode:
RESCUE linux-a5v5:~ # rear -D recover
...
Creating LVM PV /dev/mapper/cr_sda2
Creating LVM VG 'system' (some properties may not be preserved)
Creating LVM volume 'system/swap' (some properties may not be preserved)
Failed to create LVM volume 'system/swap' with lvcreate -y --stripes 1 -L 2147483648b -n swap system
Also failed to create LVM volume 'system/swap' with lvcreate -y --stripes 1 -l 100%FREE -n swap system
UserInput -I LAYOUT_CODE_RUN needed in /usr/share/rear/layout/recreate/default/200_run_layout_code.sh line 127
The disk layout recreation script failed
1) Rerun disk recreation script (/var/lib/rear/layout/diskrestore.sh)
2) View 'rear recover' log file (/var/log/rear/rear-linux-a5v5.log)
3) Edit disk recreation script (/var/lib/rear/layout/diskrestore.sh)
4) View original disk space usage (/var/lib/rear/layout/config/df.txt)
5) Use Relax-and-Recover shell and return back to here
6) Abort 'rear recover'
(default '1' timeout 300 seconds)
6
UserInput: Valid choice number result 'Abort 'rear recover''
ERROR: User chose to abort 'rear recover' in /usr/share/rear/layout/recreate/default/200_run_layout_code.sh
Some latest log messages since the last called script 200_run_layout_code.sh:
2022-07-18 10:26:59.338931642 4) View original disk space usage (/var/lib/rear/layout/config/df.txt)
2022-07-18 10:26:59.343121961 5) Use Relax-and-Recover shell and return back to here
2022-07-18 10:26:59.347923890 6) Abort 'rear recover'
2022-07-18 10:26:59.352592251 (default '1' timeout 300 seconds)
2022-07-18 10:27:10.985732018 UserInput: 'read' got as user input '6'
2022-07-18 10:27:10.992055276 UserInput: Valid choice number result 'Abort 'rear recover''
2022-07-18 10:27:10.998231743 Error detected during restore.
2022-07-18 10:27:11.002984520 Restoring saved original /var/lib/rear/layout/disklayout.conf
Aborting due to an error, check /var/log/rear/rear-linux-a5v5.log for details
Exiting rear recover (PID 3939) and its descendant processes ...
Running exit tasks
To remove the build area you may use (with caution): rm -Rf --one-file-system /var/tmp/rear.Gyh45xwJGfeklyf
Terminated
In normal mode:
RESCUE linux-a5v5:~ # rear recover
...
Creating LVM PV /dev/mapper/cr_sda2
Creating LVM VG 'system' (some properties may not be preserved)
Creating LVM volume 'system/swap' (some properties may not be preserved)
Failed to create LVM volume 'system/swap' with lvcreate -y --stripes 1 -L 2147483648b -n swap system
Also failed to create LVM volume 'system/swap' with lvcreate -y --stripes 1 -l 100%FREE -n swap system
The disk layout recreation script failed
1) Rerun disk recreation script (/var/lib/rear/layout/diskrestore.sh)
2) View 'rear recover' log file (/var/log/rear/rear-linux-a5v5.log)
3) Edit disk recreation script (/var/lib/rear/layout/diskrestore.sh)
4) View original disk space usage (/var/lib/rear/layout/config/df.txt)
5) Use Relax-and-Recover shell and return back to here
6) Abort 'rear recover'
(default '1' timeout 300 seconds)
6
ERROR: User chose to abort 'rear recover' in /usr/share/rear/layout/recreate/default/200_run_layout_code.sh
Some latest log messages since the last called script 200_run_layout_code.sh:
2022-07-18 11:07:50.063893474 3) Edit disk recreation script (/var/lib/rear/layout/diskrestore.sh)
2022-07-18 11:07:50.068134175 4) View original disk space usage (/var/lib/rear/layout/config/df.txt)
2022-07-18 11:07:50.072471816 5) Use Relax-and-Recover shell and return back to here
2022-07-18 11:07:50.077718631 6) Abort 'rear recover'
2022-07-18 11:07:50.081801160 (default '1' timeout 300 seconds)
2022-07-18 11:07:54.519945228 UserInput: 'read' got as user input '6'
2022-07-18 11:07:54.525937650 Error detected during restore.
2022-07-18 11:07:54.528824083 Restoring saved original /var/lib/rear/layout/disklayout.conf
Some messages from /var/tmp/rear.mqmYeCYdi9FiXRV/tmp/rear.recover.stdout_stderr since the last called script 200_run_layout_code.sh:
vgremove: unrecognized option '--yes'
Error during parsing of command line.
Volume group "system" successfully created
0 logical volume(s) in volume group "system" now active
lvcreate: invalid option -- 'y'
Error during parsing of command line.
lvcreate: invalid option -- 'y'
Error during parsing of command line.
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-linux-a5v5.log for details
Exiting rear recover (PID 926) and its descendant processes ...
Running exit tasks
Terminated
In non-debug mode users even could see errors from commands itself
directly on the termial when those errors are in the last messages
in the .../rear.WORKFLOW.stdout_stderr file.
pcahyna commented at 2022-07-27 09:43:¶
@jsmeix both your comments are addressed in the last commit. I am going to merge the PR soon if no further comments.
pcahyna commented at 2022-07-28 10:09:¶
@jsmeix , thanks for testing how it behaves on SLES11. Merging. By the way, it is not needed to update the supported system list in release notes, because support for SLES11 was officially dropped already in 2.7 (as noted in https://github.com/rear/rear/issues/2820#issuecomment-1153750220 )
[Export of Github issue for rear/rear.]