From b0338f7283b7d2fb25471e23b8325147e7d9cb34 Mon Sep 17 00:00:00 2001 From: Trent Lloyd Date: Wed, 30 Mar 2016 13:11:58 +0800 Subject: [PATCH] Check if /var/lib/ceph/nss exists before creation mkdir() throws an exception if the directory already exists, so we should check for it's existance before creation as hooks should be idempotent. This occurred in practice when the install hook had to be re-run, following a previous failure due to juju API timeout. It would also occur if the keystone relation was re-built, so that case is also fixed. Change-Id: I4052cda5bb20f76ab592ed7817bdc1e5b5b2138d Closes-Bug: #1563667 --- hooks/hooks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hooks/hooks.py b/hooks/hooks.py index 03aecfcb..52bca94a 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -130,7 +130,8 @@ def install(): execd_preinstall() enable_pocket('multiverse') install_packages() - os.makedirs(NSS_DIR) + if not os.path.exists(NSS_DIR): + os.makedirs(NSS_DIR) if not os.path.exists('/etc/ceph'): os.makedirs('/etc/ceph') @@ -157,7 +158,8 @@ def setup_keystone_certs(unit=None, rid=None): from keystoneclient.v2_0 import client certs_path = '/var/lib/ceph/nss' - mkdir(certs_path) + if not os.path.exists(certs_path): + mkdir(certs_path) rdata = relation_get(unit=unit, rid=rid) auth_protocol = rdata.get('auth_protocol', 'http')