Skip to content

Commit 48e7764

Browse files
Extended failure check/notification to module path and env vars on run-remote (#345)
1 parent 7e1cf64 commit 48e7764

File tree

3 files changed

+72
-28
lines changed

3 files changed

+72
-28
lines changed

redisbench_admin/run/modules.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99

1010
def redis_modules_check(local_module_files):
11+
status = True
12+
error_message = ""
1113
if local_module_files is not None:
1214
logging.info(
1315
"Using the following module artifacts: {}".format(local_module_files)
@@ -17,15 +19,14 @@ def redis_modules_check(local_module_files):
1719
"Checking if module artifact {} exists...".format(local_module_file)
1820
)
1921
if os.path.exists(local_module_file) is False:
20-
logging.error(
21-
"Specified module artifact does not exist: {}".format(
22-
local_module_file
23-
)
22+
error_message = "Specified module artifact does not exist: {}".format(
23+
local_module_file
2424
)
25-
exit(1)
25+
logging.error(error_message)
2626
else:
2727
logging.info(
2828
"Confirmed that module artifact: '{}' exists!".format(
2929
local_module_file
3030
)
3131
)
32+
return status, error_message

redisbench_admin/run_remote/run_remote.py

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,60 @@ def run_remote_command_logic(args, project_name, project_version):
121121
profilers_enabled = args.enable_profilers
122122
keep_env_and_topo = args.keep_env_and_topo
123123

124+
if WH_TOKEN is not None:
125+
webhook_notifications_active = True
126+
124127
webhook_url = "https://hooks.slack.com/services/{}".format(WH_TOKEN)
125128

126-
if args.skip_env_vars_verify is False:
127-
check_ec2_env()
129+
ci_job_link = CIRCLE_BUILD_URL
130+
ci_job_name = CIRCLE_JOB
131+
failure_reason = ""
132+
webhook_client_slack = None
133+
if ci_job_link is None:
134+
webhook_notifications_active = False
135+
logging.warning(
136+
"Disabling webhook notificaitons given CIRCLE_BUILD_URL is None"
137+
)
138+
139+
if webhook_notifications_active is True:
140+
logging.info(
141+
"Detected where in a CI flow named {}. Here's the reference link: {}".format(
142+
ci_job_name, ci_job_link
143+
)
144+
)
145+
webhook_client_slack = WebhookClient(webhook_url)
128146

129-
redis_modules_check(local_module_files)
147+
if args.skip_env_vars_verify is False:
148+
env_check_status, failure_reason = check_ec2_env()
149+
if env_check_status is False:
150+
if webhook_notifications_active:
151+
generate_failure_notification(
152+
webhook_client_slack,
153+
ci_job_name,
154+
ci_job_link,
155+
failure_reason,
156+
tf_github_org,
157+
tf_github_repo,
158+
tf_github_branch,
159+
None,
160+
)
161+
exit(1)
162+
163+
module_check_status, error_message = redis_modules_check(local_module_files)
164+
if module_check_status is False:
165+
if webhook_notifications_active:
166+
failure_reason = error_message
167+
generate_failure_notification(
168+
webhook_client_slack,
169+
ci_job_name,
170+
ci_job_link,
171+
failure_reason,
172+
tf_github_org,
173+
tf_github_repo,
174+
tf_github_branch,
175+
None,
176+
)
177+
exit(1)
130178

131179
common_properties_log(
132180
tf_bin_path,
@@ -151,20 +199,6 @@ def run_remote_command_logic(args, project_name, project_version):
151199
clusterconfig,
152200
) = prepare_benchmark_definitions(args)
153201

154-
ci_job_link = CIRCLE_BUILD_URL
155-
ci_job_name = CIRCLE_JOB
156-
failure_reason = ""
157-
webhook_notifications_active = False
158-
webhook_client_slack = None
159-
if ci_job_link is not None:
160-
logging.info(
161-
"Detected where in a CI flow named {}. Here's the reference link: {}".format(
162-
ci_job_name, ci_job_link
163-
)
164-
)
165-
webhook_notifications_active = True
166-
webhook_client_slack = WebhookClient(webhook_url)
167-
168202
return_code = 0
169203
if benchmark_defs_result is False:
170204
return_code = 1

redisbench_admin/utils/remote.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,12 +1040,21 @@ def get_overall_dashboard_keynames(
10401040

10411041

10421042
def check_ec2_env():
1043+
status = True
1044+
error_message = ""
10431045
if EC2_ACCESS_KEY is None or EC2_ACCESS_KEY == "":
1044-
logging.error("missing required AWS_ACCESS_KEY_ID env variable")
1045-
exit(1)
1046+
error_message = "missing required AWS_ACCESS_KEY_ID env variable"
1047+
status = False
1048+
10461049
if EC2_REGION is None or EC2_REGION == "":
1047-
logging.error("missing required AWS_DEFAULT_REGION env variable")
1048-
exit(1)
1050+
error_message = "missing required AWS_DEFAULT_REGION env variable"
1051+
status = False
1052+
10491053
if EC2_SECRET_KEY is None or EC2_SECRET_KEY == "":
1050-
logging.error("missing required AWS_SECRET_ACCESS_KEY env variable")
1051-
exit(1)
1054+
error_message = "missing required AWS_SECRET_ACCESS_KEY env variable"
1055+
status = False
1056+
1057+
if status is False:
1058+
logging.error(error_message)
1059+
1060+
return status, error_message

0 commit comments

Comments
 (0)