Fixing /var/run/ceph/ directory permissions

In previous versions of the charm the directory /var/run/ceph/
was created with access permissions only for root.
Consequently libvirt had no access to the rbd admin socket.

Prior installations are also fixed through update-charm.

Change-Id: I7f8054a404de9910bc070b288e1df1ce8dcf754e
Closes-Bug: #1779676
This commit is contained in:
Tilman Baumann 2018-07-03 13:31:56 +02:00
parent 35a78a0496
commit dd1d2daeb9
2 changed files with 13 additions and 0 deletions

View File

@ -15,6 +15,7 @@
import uuid
import os
import platform
import shutil
from charmhelpers.core.unitdata import kv
from charmhelpers.contrib.openstack import context
@ -326,6 +327,7 @@ class NovaComputeCephContext(context.CephContext):
asok_path = '/var/run/ceph/'
if not os.path.isdir(asok_path):
os.mkdir(asok_path)
shutil.chown(asok_path, group='kvm')
elif rbd_cache.lower() == "disabled":
ctxt['rbd_client_cache_settings'] = {'rbd cache': 'false'}

View File

@ -22,6 +22,8 @@ import uuid
import yaml
import os
import subprocess
import grp
import shutil
import charmhelpers.core.unitdata as unitdata
@ -413,6 +415,15 @@ def upgrade_charm():
if is_relation_made('nrpe-external-master'):
update_nrpe_config()
# Fix previously wrongly created path permissions
# LP: https://bugs.launchpad.net/charm-cinder-ceph/+bug/1779676
asok_path = '/var/run/ceph/'
gid = grp.getgrnam("kvm").gr_gid
if gid and os.path.isdir(asok_path) and gid != os.stat(asok_path).st_gid:
log("{} not owned by group 'kvm', fixing permissions."
.format(asok_path))
shutil.chown(asok_path, group='kvm')
@hooks.hook('nova-ceilometer-relation-changed')
@restart_on_change(restart_map())