From d02401397027ad8f7d89ecfe4d8f70f8548637b6 Mon Sep 17 00:00:00 2001 From: Matt Bruzek Date: Thu, 6 Aug 2015 15:56:23 -0500 Subject: [PATCH] Fixing an idempotency problem found in testing. --- .../trusty/kubernetes-master/hooks/install.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cluster/juju/charms/trusty/kubernetes-master/hooks/install.py b/cluster/juju/charms/trusty/kubernetes-master/hooks/install.py index 6376ee09a57..7dea5799353 100755 --- a/cluster/juju/charms/trusty/kubernetes-master/hooks/install.py +++ b/cluster/juju/charms/trusty/kubernetes-master/hooks/install.py @@ -64,7 +64,10 @@ def clone_repository(): """ repository = 'https://github.com/GoogleCloudPlatform/kubernetes.git' - kubernetes_directory = '/opt/kubernetes' + kubernetes_directory = path('/opt/kubernetes') + # Since we can not clone twice, check for the directory and remove it. + if kubernetes_directory.isdir(): + kubernetes_directory.rmtree_p() command = ['git', 'clone', repository, kubernetes_directory] print(command) @@ -75,8 +78,8 @@ def clone_repository(): def install_packages(): """ - Install required packages to build the k8s source, and syndicate between - minion nodes. In addition, fetch pip to handle python dependencies + Install required packages to build the k8s source, and syndicate between + minion nodes. In addition, fetch pip to handle python dependencies """ hookenv.log('Installing Debian packages') # Create the list of packages to install. @@ -87,8 +90,8 @@ def install_packages(): def update_rc_files(strings): """ - Preseed the bash environment for ubuntu and root with K8's env vars to - make interfacing with the api easier. (see: kubectrl docs) + Preseed the bash environment for ubuntu and root with K8's env vars to + make interfacing with the api easier. (see: kubectrl docs) """ rc_files = [path('/home/ubuntu/.bashrc'), path('/root/.bashrc')] for rc_file in rc_files: