-
Notifications
You must be signed in to change notification settings - Fork 246
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
superseded: non-interactive mode for ReaR #2979
Conversation
if is_true "$NON_INTERACTIVE"; then | ||
if ! contains_visible_char "$default_input" ; then | ||
echo "" | ||
Error "UserInput: a default value must be specified in non-interactive mode" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not right to error out
when there is no 'default_input'
because the UserInput function also
supports predefined user input values
so it could be right to error out
when there is no 'default_input'
AND no predefined user input value
but see my
#2979 (comment)
Unfortunately in current ReaR code the UserInput function There are some code places left where 'read' or 'select' |
The UserInput function is intentionally made I.e. from my current point of view I don't see @codefritzel |
The code places where UserInput is called without '-D'
As far as I see nowhere is UserInput called without '-I'
so for all cases where UserInput is called |
I see there are perhaps some cases where So I could enhance the UserInput function to error out
then the call
would just error out. |
In general see So in theory all code in ReaR should be so that it can run unattended. In theory, theory and practice are the same. In practice, they are not. I think it is more helpful in practice to fix those code places |
@codefritzel there is a lot of wisdom in what @jsmeix says here. Maybe another aproach would actually provide an easier solution? what happens if you call ReaR like this yes "" | rear recover -v In thise way every prompt will be answered with ENTER and I imagine that your login prompt would also quickly lead to a failure, which you could then detect from Ansible. Or, rather: bash -c "exec rear recover -v < <(yes '')" (bash creates the stdin input redirection and then replaces itself with rear) to easier get the return code of |
@jsmeix thanks for the tipp i did not know that at all.
This could be an alternative, but the user must know all possible inputs before.
@schlomo in my opinion these are "dirty" workarounds which only work if the inputs are not validated.
This has already been fixed in 0ebb2c but there is still a concern that this problem will occur somewhere else. In this case the desire for ReaR is to abort in such a case. I think with the non-interactive mode this would be the cleanest way to do it. If this it implemented in the relevant sections. |
@codefritzel I think the problem with that is how to distinguish For a nice example of deliberate waiting see your The good thing of this deliberate waiting is
so the waiting process is not totally idle |
Note that there is the
I think that this infinite loop case warrants some extension of
Note that there is already the |
Here is another idea: Extend the What do you think about that? |
|
@jsmeix what do you mean? That this example would not work with my suggestion? Yes, of course not. I'm still trying to find a solution for making ReaR work better in unattended mode, and especially preventing endless I don't mind modifying my suggestion so that calling |
yes, it is similar to what I meant by "or the function would abort if called some number of times for the same input and timed out" - by "same input" I meant "on the same variable" - and I meant to abort on a specific number of calls and not necessarily already at the second one. Also, to abort only if the fucntion timed out multiple times, not when the input has been entered properly. Aborting always would basically prevent using UserInput in a loop, which could also have its would also have its merits and possibly disadvantages. |
Good idea, we can count the "nobody took care of me for the N-th time" when triggering the timeout in |
@pcahyna @schlomo Now I agree with the proposed method. Regarding using the same UserInput in a loop: This is what I meant with A real-world example is similar as |
We'll rework this PR to
Any other wishes to include? I'm actually wondering if we can have (1) always active but with a higher count, e.g. 10, and then reduce that to 1 together with setting the |
I think when there is a --non-interactive flag, Or in other words: My reason for unlimited number of timeouts In particular during "rear recover" any automated abort Simply put: |
BTW, I'll keep the
I'll have a look at those and add defaults where possible. |
-S step-by-step mode; acknowledge each script individually | ||
-v verbose mode; show more output | ||
-V --version version information | ||
-n --non-interactive non-interactive mode; aborts when any user input is required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think non-interactive mode does not abort
when any user input is required,
but only when user input is required via the UserInput function
under certain timeout conditions.
@@ -12,7 +12,7 @@ rear - bare metal disaster recovery and system migration tool | |||
|
|||
|
|||
== SYNOPSIS | |||
*rear* [*-h*|*--help*] [*-V*|*--version*] [*-dsSv*] [*-D*|*--debugscripts* _SET_] [*-c* _DIR_] [*-C* _CONFIG_] [*-r* _KERNEL_] [--] _COMMAND_ [_ARGS_...] | |||
*rear* [*-h*|*--help*] [*-V*|*--version*] [*-dsSvn*] [*-D*|*--debugscripts* _SET_] [*-c* _DIR_] [*-C* _CONFIG_] [*-r* _KERNEL_] [--] _COMMAND_ [_ARGS_...] | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think --non-interactive
is missing here
doc/rear.8.adoc
Outdated
@@ -83,6 +83,9 @@ the GNU General Public License at: http://www.gnu.org/licenses/gpl.html | |||
-v:: | |||
*verbose mode* (show messages what ReaR is doing on the terminal) | |||
|
|||
-n --non-interactive:: | |||
*non-interactive mode* (ReaR aborts with an error if user input is required) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above:
I think non-interactive mode does not abort
in general when user input is required,
but only when user input is required via the UserInput function
under certain timeout conditions.
usr/share/rear/lib/help-workflow.sh
Outdated
-S step-by-step mode; acknowledge each script individually | ||
-v verbose mode; show messages what $PRODUCT is doing on the terminal or show verbose help | ||
-V --version version information | ||
-n --non-interactive non-interactive mode; aborts when any user input is required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above:
I think non-interactive mode does not abort
when any user input is required,
but only when user input is required via the UserInput function
under certain timeout conditions.
@jsmeix I just realized: Not an issue as the stuff in |
in the absence of user interaction.
This PR is superseded by #2988 |
@schlomo I think you may have misunderstood. I think in general a non-interactive / unattended mode for ReaR But in general when 'read' or 'select' is called directly Off the top of my head I know at least about |
Relax-and-Recover (ReaR) Pull Request Template
Please fill in the following items before submitting a new pull request:
Pull Request Details:
Type: Enhancement
Impact: Normal
How was this pull request tested?
manually on Ubu2204 and OL8
Brief description of the changes in this pull request:
This PR adds a non-interactive mode in ReaR.
This mode is intended when ReaR is started with an external automation tool like Ansible and there is no possibility to do an user input.
If a user input is needed, ReaR should abort with an error and not get stuck in user input loop.
The
UserInput
function has been modified so that it returns the dafault value in non-interactive mode otherwise an error is thrown.In the scripts the mode can be checked and handled with the variable
NON_INTERACTIVE
.For example, see
usr/share/rear/verify/GALAXY11/default/420_login_to_galaxy_and_setup_environment.sh
:The non-interactive mode mode can be activated with the command line option
-n
or--non-interactive
.