From 11b135e7d3385d97573d5ee8c501e251e5ba357f Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Fri, 1 Feb 2019 17:12:23 +0100 Subject: [PATCH] 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 (cherry picked from commit 898154857501b09a0101d4b7d8cbbd2c4c8b64d6) --- docker_config_scripts/nova_statedir_ownership.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docker_config_scripts/nova_statedir_ownership.py b/docker_config_scripts/nova_statedir_ownership.py index 9e5afb8b95..b8c20e3e19 100755 --- a/docker_config_scripts/nova_statedir_ownership.py +++ b/docker_config_scripts/nova_statedir_ownership.py @@ -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: + LOG.exception('Could not change ownership of %s:', + self.path) else: LOG.info('Ownership of %s already %d:%d', self.path,