Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRD ignore provider error - do not send alert #21

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions charts/tezos-reward-distributor/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,32 @@ python src/main.py \
${dry_run_arg}

# if TRD fails, send a slack alert
if [ $? -ne 0 ]; then
# Some exit codes are excluded. List of exit codes:
# https://github.com/tezos-reward-distributor-organization/tezos-reward-distributor/blob/cdf7d3884bdf880c5e13267c6d6ad3af470b2e4e/src/util/exit_program.py#L6
exit_code=$?
if [ $exit_code -ne 0 ]; then
# check if bot token and channel are set
if [ -z "${SLACK_BOT_TOKEN}" ] || [ -z "${SLACK_CHANNEL}" ]; then
echo "TRD failed, but SLACK_BOT_TOKEN or SLACK_CHANNEL is not set, failing job"
exit 1
fi
python -c "
echo "TRD exited in error, exit code is ${exit_code}, maybe send slack alert"
EXIT_CODE=${exit_code} python -c "
import os
import sys
import requests
import json

slack_bot_token = os.getenv('SLACK_BOT_TOKEN')
slack_channel = os.getenv('SLACK_CHANNEL')
baker_alias = os.getenv('BAKER_ALIAS')
exit_code = os.getenv('EXIT_CODE')

if exit_code == '9':
print(f'TRD returned exit code 9 (PROVIDER_BUSY) for Tezos baker {baker_alias}. Not alerting.')
sys.exit(0)
else:
message = f'TRD Payout failed for Tezos baker {baker_alias}, exit code {exit_code}.'
nicolasochem marked this conversation as resolved.
Show resolved Hide resolved

response = requests.post(
'https://slack.com/api/chat.postMessage',
Expand All @@ -46,7 +58,7 @@ response = requests.post(
},
data=json.dumps({
'channel': slack_channel,
'text': f'TRD Payout failed for Tezos baker {baker_alias}'
'text': message
})
)

Expand Down
Loading