don't change ownership of empty OSD directories

dirs_need_ownership_update detects when OSD directories require an
ownership change from root to ceph. However if an OSD directory exists,
but the OSD is not yet mounted, then the directory is expected to be
owned by root.

This may happen if an OSD is stopped or the OSD is no longer in use,
including on reboot when the OSD may not yet be started before hooks
run.

Change-Id: If9d7e5bcfc0b1f152643a14432e76572ac14a812
Partial-Bug: #1779828
This commit is contained in:
Trent Lloyd 2019-04-10 09:12:01 +08:00
parent 989bd67694
commit 84d384b4c5
1 changed files with 8 additions and 0 deletions

View File

@ -2700,6 +2700,14 @@ def dirs_need_ownership_update(service):
if (curr_owner == expected_owner) and (curr_group == expected_group):
continue
# NOTE(lathiat): when config_changed runs on reboot, the OSD might not
# yet be mounted or started, and the underlying directory the OSD is
# mounted to is expected to be owned by root. So skip the check. This
# may also happen for OSD directories for OSDs that were removed.
if (service == 'osd' and
not os.path.exists(os.path.join(child, 'magic'))):
continue
log('Directory "%s" needs its ownership updated' % child, DEBUG)
return True