undercloud/upgrade: change ownership for ironic-dbsync.log

A change was done in puppet-ironic:
https://review.openstack.org/#/c/457478/

It broke TripleO upgrades because ironic-dbsync.log used to be owned by
root:root and now it's managed by ironic user in puppet-ironic, which is
good.

Because we want to support existing deployments, we need a way to handle
the new owership change, so let's do it in a upgrade task in
undercloud.py. Puppet will be able to run ironic-dbsync and we'll remove
this workaround after Pike release.

Newton backport note:
  Since the Newton version does not have "upgrade" flag passed to install,
  a try..except block was added to handle fresh installations, where
  the affected file does not exist.

Co-Authored-By: Dmitry Tantsur <dtantsur@redhat.com>
Change-Id: I325c30f49b765ef6413743491902e97735877321
(cherry picked from commit 4077ec823c)
This commit is contained in:
Emilien Macchi 2017-04-25 17:30:29 -04:00 committed by Dmitry Tantsur
parent 61e201bd3c
commit 6a46ec6190
2 changed files with 21 additions and 0 deletions

View File

@ -1238,6 +1238,18 @@ def install(instack_root):
_validate_configuration()
instack_env = _generate_environment(instack_root)
_generate_init_data(instack_env)
# Even if we backport https://review.openstack.org/#/c/457478/
# into stable branches of puppet-ironic, we still need a way
# to handle existing deployments.
# This task will fix ironic-dbsync.log ownership on existing
# deployments during an upgrade. It can be removed after we
# release Pike.
try:
_run_command(['sudo', '/usr/bin/chown', 'ironic:ironic',
'/var/log/ironic/ironic-dbsync.log'])
except subprocess.CalledProcessError:
# assume it's a fresh installation, and the file does not exist
pass
_die_tuskar_die()
_run_yum_update(instack_env)
_run_instack(instack_env)

View File

@ -0,0 +1,9 @@
---
upgrade:
- |
Undercloud upgrade will handle the change of ownership for ironic-dbsync.log
to become ironic:ironic instead of root:root.
Indeed, https://review.openstack.org/#/c/457478/ broke TripleO upgrades but
it's to fix a valid issue in the puppet-ironic module. We still want to handle
upgrades for existing deployments, that's why we manage the ownership change
in instack-undercloud.