Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2111059

Summary: Evaluation enhancement of PRE_RECOVERY/POST_RECOVERY/PRE_BACKUP/POST_BACKUP scripts
Product: Red Hat Enterprise Linux 9 Reporter: Pavel Cahyna <pcahyna>
Component: rearAssignee: Pavel Cahyna <pcahyna>
Status: CLOSED ERRATA QA Contact: David Jež <djez>
Severity: medium Docs Contact: Šárka Jana <sjanderk>
Priority: medium    
Version: 9.0CC: djez, ovasik, pcahyna, rhel-cs-system-management-subsystem-qe, rmetrich
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: rear-2.6-12.el9 Doc Type: Enhancement
Doc Text:
.ReaR adds new variables for executing commands before and after recovery With this enhancement, ReaR introduces two new variables for easier automation of commands to be executed before and after recovery: * `PRE_RECOVERY_COMMANDS` accepts an array of commands. These commands will be executed before recovery starts. * `POST_RECOVERY_COMMANDS` accepts an array of commands. These commands will be executed after recovery finishes. These variables are an alternative to `PRE_RECOVERY_SCRIPT` and `POST_RECOVERY_SCRIPT` with the following differences: * The earlier `PRE_RECOVERY_SCRIPT` and `POST_RECOVERY_SCRIPT` variables accept a single shell command. To pass multiple commands to these variables, you must separate the commands by semicolons. * The new `PRE_RECOVERY_COMMANDS` and `POST_RECOVERY_COMMANDS` variables accept arrays of commands, and each element of the array is executed as a separate command. As a result, providing multiple commands to be executed in the rescue system before and after recovery is now easier and less error-prone. For more information, see the `default.conf` file.
Story Points: ---
Clone Of: 2035872 Environment:
Last Closed: 2022-11-15 10:42:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2035872    

Description Pavel Cahyna 2022-07-26 11:59:25 UTC
+++ This bug was initially created as a clone of Bug #2035872 +++

Description of problem:

Please backport PR https://github.com/rear/rear/pull/2735 once accepted Upstream.

The current evaluation of the scripts is through "eval ${SCRIPT[@]}" which has many drawbacks, in particular when using array variables, each line must be semi-colon terminated or else the rest will be skipped, e.g.

PRE_RECOVERY_SCRIPT=( 'multipathd' )
PRE_RECOVERY_SCRIPT+=( 'sleep 10' )

results in executing "multipathd sleep 10" instead of expected "multipathd" then "sleep 10".

This enhancement evaluates the scripts item by item, which is more bulletproof and still supports having the script specified as a string variable.


Version-Release number of selected component (if applicable):

All rear released including 2.6


How reproducible:

N/A

--- Additional comment from Pavel Cahyna on 2022-01-07 22:36:10 UTC ---

Hi, thanks for the PR, I left a comment there. The current behavior is indeed a bit silly, but it seems to be what was intended (except for the handling of whitespace in arguments, which is probably not as intended, and with it the whole justification for using shell arrays disappears). So, I think it is better to introduce new variables with a better-defined behavior, and let the old ones slowly die.

--- Additional comment from Pavel Cahyna on 2022-05-05 14:14:22 UTC ---

We now have a discussion upstream about other changes of semantics of POST_BACKUP. Would it be acceptable to do just the PRE/POST_RECOVERY part for now? Also, your opinion on whether to run the POST_BACKUP commands even after a failed backup is welcome (do you have more real-world scenaria than the one with DBMS stop/start?)

--- Additional comment from Pavel Cahyna on 2022-06-02 16:07:03 UTC ---

A PR implementing the new syntax for PRE/POST_RECOVERY only has been merged. Is it acceptable to add only that and avoid any additions to PRE/POST_BACKUP ? Note that PR 2735 does not preserve the original semantics of exit task handling in PRE/POST_BACKUP_SCRIPT for PRE/POST_BACKUP_COMMANDS: POST_BACKUP_SCRIPT is executed on error only if PRE_BACKUP_SCRIPT is set, as noted in https://github.com/rear/rear/pull/2735#issuecomment-1145006984, while no such logic exists for POST_BACKUP_COMMANDS.

--- Additional comment from Renaud Métrich on 2022-06-07 05:45:49 UTC ---

Hi Pavel,

I'm sorry I totally forgot this. Please do what you consider best here.

Comment 10 errata-xmlrpc 2022-11-15 10:42:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (rear bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:8246