Fuel plugin builder executes uninstall.sh upon upgrade

Bug #1564123 reported by Sergii Shevchenko
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Released
High
Alexander Kislitsky

Bug Description

It is possible to upgrade an installed Fuel plugin on place. In general it's just an RPM upgrade. Fuel plugins have quite basic RPM spec with no condition set for %preun hook.

%post hook runs post-install.sh script
%preun hook runs uninstall.sh script

https://github.com/openstack/fuel-plugins/blob/master/fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako#L40-L44

The order of operations during an upgrade is the following:

1. Run the %pre section of the RPM being installed.
2. Install the files that the RPM provides.
3. Run the %post section of the RPM.
4. Run the %preun of the old package.
5. Delete any old files not overwritten by the newer version. (This step deletes files that the new package does not require.)
6. Run the %postun hook of the old package.

As you can see uninstall.sh is running after post-install.sh script during upgrade breaking plugin installation.

It makes sense to add condition to %preun hook:

%preun
if [ "$1" -lt 1 ]; then
${ uninstall_hook }
fi

so it is not executed upon upgrade.

Steps to reproduce:

1. Create plugin with post-install.sh creating and uninstall.sh removing some directory.
2. Install plugin version "A"
3. Bump plugin version in metadata.yaml
4. Update plugin to version "B"

fuel plugins --update <plugin-B>.rpm

Expected results:

Directory created by post-install.sh exists.

Actual result:

Directory created by post-install.sh is removed during update.

Workaround:

You can create anchor files in post-install.sh showing if it's the first time post-install.sh being executed. If they exist exit from uninstall.sh.

Impact:
all plugins built using fuel plugin builder with post-install.sh and uninstall.sh scripts. Plugin engine 3+ I believe.

tags: added: area-plugins
Changed in fuel:
importance: Undecided → High
status: New → Confirmed
milestone: none → 9.0
assignee: nobody → Fuel Python Team (fuel-python)
Dmitry Pyzhov (dpyzhov)
tags: added: area-python
Dmitry Pyzhov (dpyzhov)
tags: added: feature-plugins
Changed in fuel:
assignee: Fuel Python Team (fuel-python) → Alexander Kislitsky (akislitsky)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-plugins (master)

Fix proposed to branch: master
Review: https://review.openstack.org/302306

Changed in fuel:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-plugins (master)

Reviewed: https://review.openstack.org/302306
Committed: https://git.openstack.org/cgit/openstack/fuel-plugins/commit/?id=2d24a9dbe317c0a7308fc9050e302f8cb84e9503
Submitter: Jenkins
Branch: master

commit 2d24a9dbe317c0a7308fc9050e302f8cb84e9503
Author: Alexander Kislitsky <email address hidden>
Date: Wed Apr 6 17:54:16 2016 +0300

    We shouldn't execute uninstall.sh on plugin upgrade

    When package is upgraded the following steps are perfored:
    - Run the %pre section of the RPM being installed.
    - Install the files that the RPM provides.
    - Run the %post section of the RPM.
    - Run the %preun of the old package.
    - Delete any old files not overwritten by the newer version.
      (This step deletes files that the new package does not require.)
    - Run the %postun hook of the old package.

    uninstall_hook should be executed only when package removing is
    performed. Otherwise in case of upgrade plugin changes made in
    post-install.sh can be removed by unistall.sh

    Change-Id: Idba866be2556aacc9ac0abeff67afcf34f02d93b
    Closes-Bug: #1564123

Changed in fuel:
status: In Progress → Fix Committed
tags: added: on-verification
Revision history for this message
Alex Schultz (alex-schultz) wrote :

verified on 9 #465

Changed in fuel:
status: Fix Committed → Fix Released
tags: removed: on-verification
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.