Catch directories we can not change ownership

When there is a directory where the owner can not be changed, we
fail and do not proceed to check the remaining directories. This
has been seen where netapp creates a special .snapshot directory
which is protected and visible when useing NFSv3, not visible
when using NFSv4.

This change catches the error and proceeds.

Change-Id: I2e61030c863041cd73cb204e31e423da3c6f6944
Resolves-Bug: 1814260
This commit is contained in:
Martin Schuppert 2019-02-01 17:12:23 +01:00
parent efaf0c3bea
commit 8981548575
1 changed files with 6 additions and 2 deletions

View File

@ -64,8 +64,12 @@ class PathManager(object):
self.gid,
self.uid if target_uid == -1 else target_uid,
self.gid if target_gid == -1 else target_gid)
os.chown(self.path, target_uid, target_gid)
self._update()
try:
os.chown(self.path, target_uid, target_gid)
self._update()
except Exception as e:
LOG.exception('Could not change ownership of %s: ',
self.path)
else:
LOG.info('Ownership of %s already %d:%d',
self.path,