Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UserInput in some more usual places #1573

Merged

Conversation

jsmeix
Copy link
Member

@jsmeix jsmeix commented Nov 13, 2017

Use UserInput in 500_confirm_layout_file.sh
(renamed from 500_confirm_layout.sh)
and in 100_confirm_layout_code.sh
(renamed from 100_ask_confirmation.sh)
to improve that 'rear recover' can run
unattended in migration mode, cf.
#1399

…_layout.sh) and in 100_confirm_layout_code.sh (renamed from 100_ask_confirmation.sh) to improve that 'rear recover' can run unattended in migration mode (issue 1399)
@jsmeix jsmeix added cleanup enhancement Adaptions and new features labels Nov 13, 2017
@jsmeix jsmeix added this to the ReaR v2.3 milestone Nov 13, 2017
@jsmeix jsmeix self-assigned this Nov 13, 2017
@jsmeix
Copy link
Member Author

jsmeix commented Nov 13, 2017

Now for me "rear recover" in migration mode
looks like (excerpts):

RESCUE e205:~ # rear recover
...
Current disk mapping table (source -> target):
    /dev/sda /dev/sda
Confirm or edit the disk mapping
1) Confirm disk mapping and continue 'rear recover'
2) Edit disk mapping (/var/lib/rear/layout/disk_mappings)
3) Use Relax-and-Recover shell and return back to here
4) Abort 'rear recover'
(default '1' timeout 300 seconds)

User confirmed disk mapping
Confirm or edit the disk layout file
1) Confirm disk layout and continue 'rear recover'
2) Edit disk layout (/var/lib/rear/layout/disklayout.conf)
3) View disk layout (/var/lib/rear/layout/disklayout.conf)
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)

User confirmed disk layout file
Partition primary on /dev/sda: size reduced to fit on disk.
Confirm or edit the disk recreation script
1) Confirm disk recreation script and continue 'rear recover'
2) Edit disk recreation script (/var/lib/rear/layout/diskrestore.sh)
3) View 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)

User confirmed disk recreation script
Start system layout restoration.
...

…sh) to improve that 'rear recover' is prepared so that it could theoretically run unattended even if the diskrestore.sh failed (issue 1399)
@jsmeix jsmeix requested a review from a team November 14, 2017 14:52
@jsmeix
Copy link
Member Author

jsmeix commented Nov 14, 2017

I have a question to all ReaR maintainers:

Can one of you perhaps explain to me what
the reason is for the unexpected behaviour in
https://github.com/jsmeix/rear/blob/e5d7f694212912d958168ec1238ed1bae25a50d2/usr/share/rear/layout/recreate/default/200_run_layout_code.sh
why code like

( source $LAYOUT_CODE ) && break

does not work because it seems this way
the 'set -e' inside LAYOUT_CODE does no longer work
so that then LAYOUT_CODE would no longer exit
if a command therein exits with non-zero status.
In ReaR I must explicitly test $? as follows

( source $LAYOUT_CODE )
(( $? == 0 )) && break

so that the 'set -e' inside LAYOUT_CODE still makes it
exit if a command therein exits with non-zero status.

On plain command line such code works for me

# echo 'set -e ; cat qqq ; echo hello' >script.sh

# ( source script.sh ) && echo ok || echo failed
cat: qqq: No such file or directory
failed

# echo QQQ >qqq

# ( source script.sh ) && echo ok || echo failed
QQQ
hello
ok

but it seems same kind of code does not work within ReaR.

@jsmeix jsmeix removed the request for review from a team November 14, 2017 15:49
@jsmeix
Copy link
Member Author

jsmeix commented Nov 14, 2017

I found the root cause of my question in
#1573 (comment)

In ReaR it does not work because on my SLES12 test system
where I run ReaR there is "GNU bash, version 4.3.42"
while on my SLE11 workstation where I usually try out
commands there is "GNU bash, version 3.2.51" and in
#1573 (comment)
I did the plain command line test with bash 3.x.

The bash version makes the difference here:

With bash 4.x it also does not work on plain command line:

# echo 'set -e ; cat qqq ; echo hello' >script.sh

# ( source script.sh ) && echo ok || echo failed
cat: qqq: No such file or directory
hello
ok

# ( source script.sh ) ; (( $? == 0 )) && echo ok || echo failed
cat: qqq: No such file or directory
failed

… && echo ok || echo failed' does no longer work with bash 4.x in particular not when in script.sh 'set -e' is set (issue 1399)
…' is prepared to run unattended when recreating HP SmartArray stuff (issue 1399)
@jsmeix jsmeix requested a review from gozora November 15, 2017 13:30
@jsmeix
Copy link
Member Author

jsmeix commented Nov 15, 2017

@gozora via
7b15e5c
I completely overhauled the
layout/prepare/default/200_recreate_hpraid.sh
script and I would very much appreciate it
if you could have a general look at it
https://github.com/jsmeix/rear/blob/7b15e5c3783c41d41dbf3c9fb735351633d51a6d/usr/share/rear/layout/prepare/default/200_recreate_hpraid.sh
whether or not you see perhaps immediate mistakes.
Many thanks in advance!

…pt.sh ) && echo ok || echo failed' does not work with bash 4.x in particular not when in script.sh 'set -e' is set (issue 1399)
@gozora
Copy link
Member

gozora commented Nov 15, 2017

Hello @jsmeix

What I can tell you from top of my head.

grep -q '^cciss ' /proc/modules || return 0

cciss is no longer module to be used, HP(E) switched to hpsa some time ago.
hpsa uses standard SCSI disk names for SmarArray logical disks (/dev/sd[a-z] instead of /dev/cciss/...) so I'm not sure if whole code in 200_recreate_hpraid.sh will work on modern systems ...

Unfortunately I don't have access to any HPE test HW right now, so I can't really tell you whether recreation of SmartArray works or not :-(
I'll however keep this in mind and as soon as I have an opportunity to test it, I'll do so.

V.

@gozora
Copy link
Member

gozora commented Nov 15, 2017

Topic of creating SmarArray (SA) from OS can be even more complicated due special branch of SA called HPE Dynamic Smart Array (cf. specification link) which is "kind of" smart array but can be used only in UEFI mode and uses different Linux driver hpdsa dependent on hpsa.

I actually never used ReaR feature for creating logical volumes during restore process, but rather created them manually prior rear recover

V.

@jsmeix
Copy link
Member Author

jsmeix commented Nov 15, 2017

I tried hard to not change what the code
in 200_recreate_hpraid.sh actually does.
I do not have such hardware so that I cannot
change what that code actually does.

I only changed (i.e. cleaned up) the syntax and
replaced the 'read' and 'select' calls by UserInput()
so that the new 200_recreate_hpraid.sh again
matches the new 200_run_layout_code.sh.

@jsmeix
Copy link
Member Author

jsmeix commented Nov 15, 2017

Regarding
"cciss is no longer module to be used, HP(E) switched to hpsa"
I had noticed that in
http://cciss.sourceforge.net/
which reads

The cciss driver has been removed from RHEL7 and SLES12.
If you really want cciss on RHEL7 checkout the elrepo directory.
A new Smart Array driver called "hpsa" has been accepted into
the main line linux kernel as of Dec 18, 2009, in linux-2.6.33-rc1.
This new driver will support new Smart Array products going
forward, and the cciss driver will eventually be deprecated. 

Accordingly my hopefully non-behavioural changes
in 200_recreate_hpraid.sh are not of real importance
nowadays so that I can more easily merge it without
too much fear about possible regressions related to
CCISS HP Smart Array setups.

…ay controillers that use the cciss kernel module which will eventually be deprecated (issue 1399)
@jsmeix jsmeix merged commit d334ad1 into rear:master Nov 15, 2017
@jsmeix jsmeix deleted the use_UserInput_at_some_more_usual_places_issue_1399 branch November 15, 2017 16:50
@jsmeix
Copy link
Member Author

jsmeix commented Nov 15, 2017

@gozora
many thanks for your prompt review!

@gozora
Copy link
Member

gozora commented Nov 15, 2017

@jsmeix anytime ;-)

@jsmeix
Copy link
Member Author

jsmeix commented Nov 15, 2017

FWIW:
For me on my SLES12 test system the new stuff works really well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants