From 97467c38c4df5ccd0a35bfa1c7626b0aceea0806 Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Tue, 9 May 2017 11:18:39 +0800 Subject: [PATCH] Catch exception during calling os.chmod in set_configs.py set_perms may fail in some case, but it is not critical. Just leave a warning rather than exit. Change-Id: I757c7b60611fb6c0547bd1b26ec8a8af03684e5f Closes-Bug: 1689454 --- docker/base/set_configs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py index 9c3d1f1e45..eb4b7ac17d 100644 --- a/docker/base/set_configs.py +++ b/docker/base/set_configs.py @@ -354,7 +354,13 @@ def handle_permissions(config): def set_perms(path, uid, gid): LOG.info('Setting permission for %s', path) - os.chown(path, uid, gid) + if not os.path.exists(path): + LOG.warning('file %s do not exist', path) + return + try: + os.chown(path, uid, gid) + except OSError: + LOG.exception('Set file permission failed for %s', path) for dest in glob.glob(path): set_perms(dest, uid, gid)