From b7fb38cc9ec92f76284def14dd0c3fbf4d6bc2f7 Mon Sep 17 00:00:00 2001 From: Nacho Rivera <59198746+n4ch04@users.noreply.github.com> Date: Mon, 17 Oct 2022 14:03:55 +0200 Subject: [PATCH] fix(extra7184): Error handling GetSnapshotLimits api call (#1411) --- checks/check_extra7184 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/checks/check_extra7184 b/checks/check_extra7184 index 5e9293fad6..8520d8ee15 100644 --- a/checks/check_extra7184 +++ b/checks/check_extra7184 @@ -42,11 +42,15 @@ extra7184(){ textInfo "${regx}: Access Denied trying to get Directiory Service snapshot limits" "${regx}" continue fi + if grep -q -E 'ClientException' <<< "${LIMIT_DATA}"; then + textInfo "${regx}: Error calling the GetSnapshotLimits operation: Snapshot limits can be fetched only for VPC or Microsoft AD directories (directory id: ${DIRECTORY_ID})" "${regx}" + continue + fi echo "${LIMIT_DATA}" | while read -r CURRENT_SNAPSHOTS_COUNT SNAPSHOTS_LIMIT SNAPSHOTS_LIMIT_REACHED; do - if [[ ${SNAPSHOTS_LIMIT_REACHED} == "true" ]] + if [[ ${SNAPSHOTS_LIMIT_REACHED} == "true" ]] then textFail "${regx}: Directory Service ${DIRECTORY_ID} reached ${SNAPSHOTS_LIMIT} Snapshots Limit" "${regx}" "${DIRECTORY_ID}" - else + else LIMIT_REMAIN=$(("${SNAPSHOTS_LIMIT}" - "${CURRENT_SNAPSHOTS_COUNT}")) if [[ "${LIMIT_REMAIN}" -le "${THRESHOLD}" ]]; then textFail "${regx}: Directory Service ${DIRECTORY_ID} is about to reach ${SNAPSHOTS_LIMIT} snapshots which is the limit" "${regx}" "${DIRECTORY_ID}"