Bug 1526375 - tendrl-api rpm %post, %preun, %postun scripts should correctly handle systemd service
Summary: tendrl-api rpm %post, %preun, %postun scripts should correctly handle systemd...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Gluster Storage
Classification: Red Hat Storage
Component: web-admin-tendrl-api
Version: rhgs-3.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: RHGS 3.4.0
Assignee: Shirshendu Mukherjee
QA Contact: Daniel Horák
URL:
Whiteboard:
Depends On:
Blocks: 1503134
TreeView+ depends on / blocked
 
Reported: 2017-12-15 10:04 UTC by Daniel Horák
Modified: 2018-09-04 07:01 UTC (History)
3 users (show)

Fixed In Version: tendrl-ansible-1.6.1-2.el7rhgs.noarch.rpm, tendrl-api-1.6.1-1.el7rhgs.noarch.rpm, tendrl-commons-1.6.1-1.el7rhgs.noarch.rpm, tendrl-monitoring-integration-1.6.1-1.el7rhgs.noarch.rpm, tendrl-node-agent-1.6.1-1.el7, tendrl-ui-1.6.1-1.el7rhgs.noarch.rpm,
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-09-04 07:00:31 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github Tendrl api issues 378 0 None None None 2018-03-08 09:11:35 UTC
Red Hat Product Errata RHSA-2018:2616 0 None None None 2018-09-04 07:01:24 UTC

Description Daniel Horák 2017-12-15 10:04:55 UTC
Description of problem:
  Spec file for tendrl-api package doesn't contain any %post, %preun and %postun scripts to notify systemd about the performed changes.

  So for example, after uninstalling tendrl-api, `systemctl status tendrl-api` command return:

    Failed to get properties: Access denied

  instead of expected:

    Unit tendrl-api.service could not be found.

  And there are some other situations when the systemd is in slightly inconsistent state after install/uninstall of tendrl-api package.

Version-Release number of selected component (if applicable):
  tendrl-api-1.5.4-4.el7rhgs.noarch

Actual results:
  tendrl-api.spec file doesn't contain any pre/post in/uninstall scripts to notify systemd about the changes

Expected results:
  tendrl-api.spec file should contain required pre/post in/uninstall scripts to notify systemd about the changes

Additional info:
  For example (and for inspiration), httpd.spec file contains following definitions:

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  %post
  %systemd_post httpd.service htcacheclean.service

  %preun
  %systemd_preun httpd.service htcacheclean.service

  %postun
  %systemd_postun
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Comment 2 Daniel Horák 2018-05-11 07:37:15 UTC
Tested and verified with:
  tendrl-api-1.6.3-3.el7rhgs.src.rpm

The specfile now contains expected macros:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  %post
  %systemd_post tendrl-api.service

  %preun
  %systemd_preun tendrl-api.service

  %postun
  %systemd_postun_with_restart tendrl-api.service
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And they are correctly expanded to post/preun/postun scripts:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # rpm -q tendrl-api --scripts
  <<truncated>>
  postinstall scriptlet (using /bin/sh):

  if [ $1 -eq 1 ] ; then 
          # Initial installation 
          systemctl preset tendrl-api.service >/dev/null 2>&1 || : 
  fi
  preuninstall scriptlet (using /bin/sh):

  if [ $1 -eq 0 ] ; then 
          # Package removal, not upgrade 
          systemctl --no-reload disable tendrl-api.service > /dev/null 2>&1 || : 
          systemctl stop tendrl-api.service > /dev/null 2>&1 || : 
  fi
  postuninstall scriptlet (using /bin/sh):

  systemctl daemon-reload >/dev/null 2>&1 || : 
  if [ $1 -ge 1 ] ; then 
          # Package upgrade, not uninstall 
          systemctl try-restart tendrl-api.service >/dev/null 2>&1 || : 
  fi
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Also case with uninstalling tendrl-api and trying to get status of tendrl-api
service fails with correct error:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # systemctl status tendrl-api
  Unit tendrl-api.service could not be found.
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

>> VERIFIED

Comment 4 errata-xmlrpc 2018-09-04 07:00:31 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, 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-2018:2616


Note You need to log in before you can comment on or make changes to this bug.