From a7f5eae270b2922a04dcf0ff4bc2183b0d0cee4f Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Wed, 12 Jul 2017 16:47:19 -0700 Subject: [PATCH] Check existence of ceph binaries in add-storage hook Add a check to make sure that the ceph package is installed in the add-storage shim. The add-storage hook is run prior to the install hook in order to provide storage for the install phase of the charm in cases where it is needed. The ceph-osd charm converts Juju storage into OSDs and doesn't need the storage for the install hook, so just skip the hook if its run early. Change-Id: I7b7518f52d0b5ad947b0809af8ad67d342211779 Closes-Bug: #1675186 --- hooks/add-storage | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hooks/add-storage b/hooks/add-storage index 5b02c170..cec4d4cf 100755 --- a/hooks/add-storage +++ b/hooks/add-storage @@ -1,7 +1,17 @@ #!/bin/bash -# Wrapper to deal with newer Ubuntu versions that don't have py2 installed -# by default. +# shim used to determine that the ceph packages have been installed +# before running hook execution. The add-storage hook fires before +# the install hook in order to provide storage for charms which need +# it at install time, however the storage added for the ceph-osd +# application will be used to create OSDs, which require the ceph +# binaries, bootstrapping the node, etc. +# +# Note: this doesn't wait to ensure that ceph is bootstrapped because +# that logic is already existing in the charm's hook. -dpkg -l|grep 'python-apt ' || exit 0 +if ! dpkg -s ceph > /dev/null 2>&1; then + juju-log "Ceph not yet installed." + exit 0 +fi -exec ./hooks/storage.real \ No newline at end of file +exec ./hooks/storage.real