Skip to content

Commit

Permalink
Merge pull request #25 from edenlabllc/release/v1.29.1
Browse files Browse the repository at this point in the history
Fix clickhouse-hook.sh to support multiple CH installations.
  • Loading branch information
anovikov-el authored Jan 9, 2025
2 parents a0f8ec5 + 6e04c3c commit 91f9d19
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions bin/clickhouse-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,29 @@ NAMESPACE="${2:-clickhouse}"
ACTION="${3}"
LIMIT="${4:-180}"

COUNT=1
function check_cr() {
local OUTPUT="${1}"

function watcher() {
if [[ "${STATUS}" != "${PHRASE}" && "${COUNT}" -le "${LIMIT}" ]]; then
if [[ "${OUTPUT}" != "true" && "${COUNT}" -le "${LIMIT}" ]]; then
sleep 1
((++COUNT))
elif [[ "${COUNT}" -gt "${LIMIT}" ]]; then
>2& echo "Limit exceeded."
exit 1
else
kubectl -n "${NAMESPACE}" get clickHouseinstallation 2>&1
kubectl -n "${NAMESPACE}" get clickhouseinstallation "${RELEASE_NAME}" --ignore-not-found

exit 0
fi
}

COUNT=1
if [[ "${ACTION}" == "delete" ]]; then
PHRASE="No resources found in ${NAMESPACE} namespace."
while true; do
STATUS=$(kubectl -n "${NAMESPACE}" get clickHouseinstallation 2>&1)
watcher
check_cr "$(kubectl -n "${NAMESPACE}" get clickhouseinstallation "${RELEASE_NAME}" --ignore-not-found -o yaml | yq "length == 0")"
done
else
PHRASE="Completed"
while true; do
STATUS=$(kubectl -n "${NAMESPACE}" get clickHouseinstallation | head -2 | grep "${RELEASE_NAME}" | awk '{print $4}')
watcher
check_cr "$(kubectl -n "${NAMESPACE}" get clickhouseinstallation "${RELEASE_NAME}" --ignore-not-found -o yaml | yq ".status.status == \"Completed\"")"
done
fi

0 comments on commit 91f9d19

Please sign in to comment.