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

#1886 - LPAR/PPC64 bootlist is incorrectly set when having multiple 'prep' partitions #1887

Merged
merged 2 commits into from Aug 8, 2018

Conversation

rmetrich
Copy link
Contributor

@rmetrich rmetrich commented Aug 1, 2018

Relax-and-Recover (ReaR) Pull Request Template

Please fill in the following items before submitting a new pull request:

Pull Request Details:
  • Type: Bug Fix

  • Impact: Normal

  • Reference to related issue (URL): https://github.com/rear/rear/issues/1886

  • How was this pull request tested?

    Tested on AIX/LPAR/PPC64le with 2 prep partitions, but no multipath on older ReaR 2.00 version

  • Brief description of the changes in this pull request:

    • Added handling of multiple prep partitions
    • Enhanced handling of multiple prep partitions and multipath

…le 'prep' partitions

- Added handling of multiple 'prep' partitions
- Enhanced handling of multiple 'prep' partitions and multipath
@jsmeix jsmeix requested a review from schabrolles August 1, 2018 09:25
@jsmeix jsmeix added bug The code does not do what it is meant to do cleanup labels Aug 1, 2018
@jsmeix jsmeix added this to the ReaR v2.5 milestone Aug 1, 2018

if [[ ${#boot_list[@]} -gt 0 ]]; then
LogPrint "Set LPAR bootlist to '${boot_list[@]}'"
bootlist -m normal $boot_list
LogIfError "Unable to set bootlist. You will have to start in SMS to set it up manually."
Copy link
Member

@jsmeix jsmeix Aug 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regadless that this is not part of this pull request but in general
I think LogIfError is useless to tell something to the user
because the LogIfError output appears only in the log file.
To show an error message to the user better use LogPrintIfError
or whatever appropriate function in lib/_input-output-functions.sh

@jsmeix
Copy link
Member

jsmeix commented Aug 6, 2018

@schabrolles
could you have a look here an review it?
If you don't have time I would "just merge" it tomorrow
because it was tested by @rmetrich

@jsmeix
Copy link
Member

jsmeix commented Aug 8, 2018

@schabrolles
I would like to "just merge" it today afternoon if you do not object, cf.
#1887 (comment)

@schabrolles
Copy link
Member

@jsmeix, bootlist is responsible to set the boot devices order list for an LPAR in PowerVM.
Unfortunately, My PowerVM system is used for a customer test until end of August. So I'm not able to perform a test to validate it.

@jsmeix
Copy link
Member

jsmeix commented Aug 8, 2018

@schabrolles
does this pull request look o.k. to you from plain looking at the code
or do you perhaps immediately see something that could be wrong?
If things look o.k. to you, you could approve the pull request with
an appropriate approval comment that you only looked at the code.

@schabrolles
Copy link
Member

@jsmeix, for a plain looking code, this looks correct to me...

@jsmeix jsmeix merged commit a477df1 into rear:master Aug 8, 2018
@jsmeix
Copy link
Member

jsmeix commented Aug 8, 2018

@rmetrich
many thanks for your fix and enhancements!

@schabrolles
many thanks for your review!


if [[ ${#boot_list[@]} -gt 0 ]]; then
LogPrint "Set LPAR bootlist to '${boot_list[@]}'"
bootlist -m normal $boot_list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanding $boot_list this way will return only the first element. Is it intended? Why is boot_list an array if it is intended - one element would be enough?
IIUC, this will lead to boot failure if the first path is disconnected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ough, this is indeed broken!

fi

if [[ ${#boot_list[@]} -gt 0 ]]; then
LogPrint "Set LPAR bootlist to '${boot_list[@]}'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ${boot_list[@]} inside double quotes will cause it to expand to multiple strings, like this:

boot_list=( foo bar )
"Set LPAR bootlist to '${boot_list[@]}'" -> "Set LPAR bootlist to 'foo"   "bar'"

LogPrint actually handles multiple arguments properly, so it is not a bug. But it is IMO better to do this in a less surprising way, because I don't think this kind of splitting into multiple argument was intended. And it can become a bug when this code gets cargo-culted to other places. And it is flagged by static analysis: https://github.com/koalaman/shellcheck/wiki/SC2145.
I propose:

LogPrint "Set LPAR bootlist to '${boot_list[*]}'"

(mentioned also in #2097 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed #2098 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The code does not do what it is meant to do cleanup enhancement Adaptions and new features fixed / solved / done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants