Bug 1770366

Summary: [RFE] Improve upgrade efficiency by moving RPM post-installation scripts to the installer.
Product: Red Hat Satellite Reporter: Dylan Gross <dgross>
Component: PackagingAssignee: Eric Helms <ehelms>
Status: CLOSED ERRATA QA Contact: Lukas Pramuk <lpramuk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6.0CC: ahumbe, bkearney, egolov, ehelms
Target Milestone: 6.8.0Keywords: FutureFeature, PrioBumpGSS, Triaged
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 12:59:24 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:

Description Dylan Gross 2019-11-08 19:56:55 UTC
1. Proposed title of this feature request

   Improve Satellite upgrade efficiency by moving RPM post-installation scripts to the installer.

3. What is the nature and description of the request?

   At present, there at least nine RPMs that perform the same post-installation actions.  During a Satellite upgrade, the process would therefore repeat at least nine times the following actions....

~~~
    /usr/sbin/foreman-rake db:migrate >> /var/log/foreman/db_migrate.log 2>&1 || :
    /usr/sbin/foreman-rake db:seed >> /var/log/foreman/db_seed.log 2>&1 || :
    /usr/sbin/foreman-rake apipie:cache:index >> /var/log/foreman/apipie_cache.log 2>&1 || :
    (touch /usr/share/foreman/tmp/restart.txt ; /bin/systemctl try-restart foreman.service) >/dev/null 2>&1
    exit 0
~~~

   This can extend the time it takes to do an upgrade (and thus increase the length of an outage).

4. Why does the customer need this? (List the business requirements here)

   To minimize downtime due to upgrades.

5. How would the customer like to achieve this? (List the functional requirements here)

    Those three foreman-rake calls are executed as RPM post-install scripts when the RPMs are updated.  They could potentially be executed only once by the installer after installation instead of once for each RPM.

6. For each functional requirement listed, specify how Red Hat and the customer can test to confirm the requirement is successfully implemented.

   Verify that the installer is executing those actions after one of those RPMs is updated.

7. Is there already an existing RFE upstream or in Red Hat Bugzilla?

   I have not found an existing RFE upstream or in Red Hat Bugzilla, but this appears to have been an active discussion here:   https://community.theforeman.org/t/database-and-service-actions-in-rpm-post-scripts/7311/13

8. Does the customer have any specific timeline dependencies and which release would they like to target (i.e. RHEL5, RHEL6)?

   No

9. Is the sales team involved in this request and do they have any additional input?

   No

10. List any affected packages or components.

  The following RPMs were identified as making these (or very similar calls).  However, there may be more optionally-installed ones that haven't been found yet.

    foreman-1.22.0.32-1.el7sat.noarch
    tfm-rubygem-foreman-tasks-0.15.11.1-1.el7sat
    tfm-rubygem-foreman_bootdisk-15.0.0-1.el7sat
    tfm-rubygem-foreman_discovery-15.0.2-1.el7sat
    tfm-rubygem-foreman_openscap-1.0.8-1.el7sat
    tfm-rubygem-foreman_remote_execution-1.8.0.4-1.el7sat
    tfm-rubygem-redhat_access-2.2.8-1.el7sat
    tfm-rubygem-foreman_templates-6.0.3-2.el7sat
    tfm-rubygem-foreman_ansible-3.0.7.1-1.el7sat

11. Would the customer be able to assist in testing this functionality if implemented?

    Yes.

Comment 5 Lukas Pramuk 2020-08-31 14:11:55 UTC
FailedQA.

@Satellite 6.8.0 Snap12
tfm-rubygem-redhat_access-2.2.13-1.el7sat.noarch

# for p in foreman tfm-rubygem-foreman-tasks tfm-rubygem-foreman_bootdisk tfm-rubygem-foreman_discovery tfm-rubygem-foreman_openscap tfm-rubygem-foreman_remote_execution tfm-rubygem-redhat_access tfm-rubygem-foreman_templates tfm-rubygem-foreman_ansible; do echo === $p ================= ; rpm -q --scripts $p | grep foreman-rake ; done 

=== foreman =================
  /usr/sbin/foreman-rake security:generate_token >/dev/null 2>&1 || :
  /usr/sbin/foreman-rake security:generate_encryption_key >/dev/null 2>&1 || :
=== tfm-rubygem-foreman-tasks =================
=== tfm-rubygem-foreman_bootdisk =================
=== tfm-rubygem-foreman_discovery =================
=== tfm-rubygem-foreman_openscap =================
=== tfm-rubygem-foreman_remote_execution =================
=== tfm-rubygem-redhat_access =================
/usr/sbin/foreman-rake db:migrate >> /var/log/foreman/db_migrate.log 2>&1 || :
/usr/sbin/foreman-rake db:seed >> /var/log/foreman/db_seed.log 2>&1 || :
/usr/sbin/foreman-rake apipie:cache:index >> /var/log/foreman/apipie_cache.log 2>&1 || :
=== tfm-rubygem-foreman_templates =================
=== tfm-rubygem-foreman_ansible =================


>>> yet tfm-rubygem-redhat_access rpm postscript contains db:migrate, db:seed and apipie:cache:index tasks

Comment 6 Lukas Pramuk 2020-09-07 15:49:17 UTC
This shouldn't be ON_QA as satellite6/satellite-packaging/merge_requests/4440 is still open

Comment 7 Lukas Pramuk 2020-09-21 15:53:40 UTC
VERIFIED.

@Satellite 6.8.0 Snap16
foreman-2.1.2.12-1.el7sat.noarch
tfm-rubygem-foreman-tasks-2.0.2-1.fm2_1.el7sat.noarch
tfm-rubygem-foreman_bootdisk-17.0.2-2.fm2_1.el7sat.noarch
tfm-rubygem-foreman_discovery-16.1.0-1.el7sat.noarch
tfm-rubygem-foreman_openscap-4.0.3-1.fm2_1.el7sat.noarch
tfm-rubygem-foreman_remote_execution-3.3.7-1.el7sat.noarch
tfm-rubygem-redhat_access-2.2.17-1.fm2_1.el7sat.noarch
tfm-rubygem-foreman_templates-9.0.1-1.fm2_1.el7sat.noarch
tfm-rubygem-foreman_ansible-5.1.3-1.el7sat.noarch

# for p in foreman tfm-rubygem-foreman-tasks tfm-rubygem-foreman_bootdisk tfm-rubygem-foreman_discovery tfm-rubygem-foreman_openscap tfm-rubygem-foreman_remote_execution tfm-rubygem-redhat_access tfm-rubygem-foreman_templates tfm-rubygem-foreman_ansible; do echo === $p ================= ; rpm -q --scripts $p | grep foreman-rake ; done 

=== foreman =================
  /usr/sbin/foreman-rake security:generate_token >/dev/null 2>&1 || :
  /usr/sbin/foreman-rake security:generate_encryption_key >/dev/null 2>&1 || :
=== tfm-rubygem-foreman-tasks =================
=== tfm-rubygem-foreman_bootdisk =================
=== tfm-rubygem-foreman_discovery =================
=== tfm-rubygem-foreman_openscap =================
=== tfm-rubygem-foreman_remote_execution =================
=== tfm-rubygem-redhat_access =================
=== tfm-rubygem-foreman_templates =================
=== tfm-rubygem-foreman_ansible =================


>>> these rpms postscripts no longer contain db:migrate, db:seed and apipie:cache:index tasks (speeding up rpm installation/update)

Comment 10 errata-xmlrpc 2020-10-27 12:59:24 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 (Important: Satellite 6.8 release), 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/RHSA-2020:4366