Skip to content

Commit

Permalink
fix: Fail as unsupported when inputs are bad
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkro committed Dec 16, 2023
1 parent 484f8d6 commit 503a321
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions recipes/newrelic/infrastructure/ohi/cassandra/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ install:
- task: input_assert
vars:
MAX_RETRIES: 3
EXIT130: ""
EXIT131: ""
- task: restart

assert_pre_req:
Expand Down Expand Up @@ -154,17 +154,17 @@ install:
if [[ "$NEW_RELIC_ASSUME_YES" == "true" ]]; then
NODETOOL_RESPONSE=$(nodetool -p "$NEW_RELIC_CASSANDRA_PORT" -h "$NEW_RELIC_CASSANDRA_HOSTNAME" -u "$NEW_RELIC_CASSANDRA_USERNAME" -pw "$NEW_RELIC_CASSANDRA_PASSWORD" version 2>&1)
if [ $(echo $NODETOOL_RESPONSE | grep -i "Failed to connect" | wc -l) -gt 0 ]; then
EXIT130=" - NEW_RELIC_CASSANDRA_PORT=<port>\n - NEW_RELIC_CASSANDRA_HOSTNAME=<hostname>"
EXIT131=" - NEW_RELIC_CASSANDRA_PORT=<port>\n - NEW_RELIC_CASSANDRA_HOSTNAME=<hostname>"
fi
if [ $(echo $NODETOOL_RESPONSE | grep -Ei "Invalid username or password|Required values.*not provided" | wc -l) -gt 0 ]; then
EXIT130=" - NEW_RELIC_CASSANDRA_USERNAME=<jmx_username>\n - NEW_RELIC_CASSANDRA_PASSWORD=<jmx_user_password>"
EXIT131=" - NEW_RELIC_CASSANDRA_USERNAME=<jmx_username>\n - NEW_RELIC_CASSANDRA_PASSWORD=<jmx_user_password>"
fi
fi
if [ "$EXIT130" != "" ]; then
printf "There is a problem with the required environment variables. Please set the following variable(s) and try again:\n\n$EXIT130\n"
exit 130
if [ "$EXIT131" != "" ]; then
printf "There is a problem with the required environment variables. Please set the following variable(s) and try again:\n\n$EXIT131\n"
exit 131
else
printf "\n[OK] All checks passed. Installing Cassandra Integration...\n\n"
fi
Expand Down
12 changes: 6 additions & 6 deletions recipes/newrelic/infrastructure/ohi/cassandra/rhel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ install:
- task: input_assert
vars:
MAX_RETRIES: 3
EXIT130: ""
EXIT131: ""
- task: restart

assert_pre_req:
Expand Down Expand Up @@ -159,17 +159,17 @@ install:
if [[ "$NEW_RELIC_ASSUME_YES" == "true" ]]; then
NODETOOL_RESPONSE=$(nodetool -p "$NEW_RELIC_CASSANDRA_PORT" -h "$NEW_RELIC_CASSANDRA_HOSTNAME" -u "$NEW_RELIC_CASSANDRA_USERNAME" -pw "$NEW_RELIC_CASSANDRA_PASSWORD" version 2>&1)
if [ $(echo $NODETOOL_RESPONSE | grep -i "Failed to connect" | wc -l) -gt 0 ]; then
EXIT130=" - NEW_RELIC_CASSANDRA_PORT=<port>\n - NEW_RELIC_CASSANDRA_HOSTNAME=<hostname>"
EXIT131=" - NEW_RELIC_CASSANDRA_PORT=<port>\n - NEW_RELIC_CASSANDRA_HOSTNAME=<hostname>"
fi
if [ $(echo $NODETOOL_RESPONSE | grep -Ei "Invalid username or password|Required values.*not provided" | wc -l) -gt 0 ]; then
EXIT130=" - NEW_RELIC_CASSANDRA_USERNAME=<jmx_username>\n - NEW_RELIC_CASSANDRA_PASSWORD=<jmx_user_password>"
EXIT131=" - NEW_RELIC_CASSANDRA_USERNAME=<jmx_username>\n - NEW_RELIC_CASSANDRA_PASSWORD=<jmx_user_password>"
fi
fi
if [ "$EXIT130" != "" ]; then
printf "There is a problem with the required environment variables. Please set the following variable(s) and try again:\n\n$EXIT130\n"
exit 130
if [ "$EXIT131" != "" ]; then
printf "There is a problem with the required environment variables. Please set the following variable(s) and try again:\n\n$EXIT131\n"
exit 131
else
printf "\n[OK] All checks passed. Installing Cassandra Integration...\n\n"
fi
Expand Down

0 comments on commit 503a321

Please sign in to comment.