Skip to content
Snippets Groups Projects
Commit 4c8c176b authored by Recolic K's avatar Recolic K
Browse files

bug fix: previous commit introduces a bug

parent 882c48dd
No related branches found
No related tags found
No related merge requests found
...@@ -197,33 +197,31 @@ function cis_get_job_status () { ...@@ -197,33 +197,31 @@ function cis_get_job_status () {
jobid="$1" jobid="$1"
getjobhierarchy_apires=`curl_wrapped "https://beta-cps.trafficmanager.net/cis.client.svc/Public/$cis_namespace/GenericJob/$jobid/GetJobHierarchy"` && getjobhierarchy_apires=`curl_wrapped "https://beta-cps.trafficmanager.net/cis.client.svc/Public/$cis_namespace/GenericJob/$jobid/GetJobHierarchy"` &&
subworkflows_text=`echo "$getjobhierarchy_apires" | json2table DisplayName,Id,DisplayStatus,JobType -p` || ! echo2 "API GetJobHierarchy failed. Server says '$getjobhierarchy_apires'" || return $? subworkflows_text=`echo "$getjobhierarchy_apires" | json2table DisplayName,Id,DisplayStatus,JobType -p` || ! echo2 "API GetJobHierarchy failed. Server says '$getjobhierarchy_apires'" || return $?
callstack_formatted=`echo "$getjobhierarchy_apires" | json2table DisplayName,Id,DisplayStatus | grep -E '( InProgress )|( PlanError )|( Internal Error )'` # Ignore failure because it's only useful in InProgress and PlanError state. _ts='```'
_mdcode='```'
# RemoteJob may have some known bad states in subworkflow. The top-level workflow is still InProgress but bottom workflow has boomed.
echo "DEBUG: $subworkflows_text" bad_states=(
if planerror_callstack=`echo "$subworkflows_text" | grep -F '|PlanError|'`; then 'PlanError'
# RemoteJob may have PlanError in subworkflow. The top-level workflow is still InProgress but bottom workflow got PlanError. 'Internl Error'
[[ -z "$callstack_formatted" ]] && echo2 "API GetJobHierarchy result misinterpreted. No workflow in stat InProgress or PlanError or InternalError. This is an unexpected non-fatal error and I did not catch it. " && return 2 'Aborted'
[[ -z $ANTIDOTE_JOBSTAT_MARKDOWN ]] && )
echo2 -e ">>> CIS reported PlanError:\nCallstack: \n$callstack_formatted\nCIS Log: https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid" || callstack_in_email=`echo "$getjobhierarchy_apires" | json2table DisplayName,Id,DisplayStatus | grep -E '( InProgress )|( PlanError )|( Internal Error )|( Aborted )'`
echo2 -e "## CIS reported PlanError\n\n[View CIS Log](https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid)\n\n### Callstack\n\n$_mdcode\n$callstack_formatted\n$_mdcode\n" for bad_state in "${bad_states[@]}"; do
echo "Failed" && return 0 if planerror_callstack=`echo "$subworkflows_text" | grep -F "|$bad_state|"`; then
fi [[ -z "$callstack_in_email" ]] && echo2 "API GetJobHierarchy result misinterpreted. No workflow in state $bad_state. This is an unexpected non-fatal error and I did not catch it. " && return 2
if planerror_callstack=`echo "$subworkflows_text" | grep -F '|Internal Error|'`; then [[ -z $ANTIDOTE_JOBSTAT_MARKDOWN ]] &&
# RemoteJob may have PlanError in subworkflow. The top-level workflow is still InProgress but bottom workflow got PlanError. echo2 -e ">>> CIS reported $bad_state:\nCallstack: \n$callstack_in_email\nCIS Log: https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid" ||
[[ -z "$callstack_formatted" ]] && echo2 "API GetJobHierarchy result misinterpreted. No workflow in stat InProgress or PlanError or InternalError. This is an unexpected non-fatal error and I did not catch it. " && return 2 echo2 -e "## CIS reported $bad_state\n\n[View CIS Log](https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid)\n\n### Callstack\n\n$_ts\n$callstack_in_email\n$_ts\n"
[[ -z $ANTIDOTE_JOBSTAT_MARKDOWN ]] && echo "Failed" && return 0
echo2 -e ">>> CIS reported Internal Error:\nCallstack: \n$callstack_formatted\nCIS Log: https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid" || fi
echo2 -e "## CIS reported Internal Error\n\n[View CIS Log](https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid)\n\n### Callstack\n\n$_mdcode\n$callstack_formatted\n$_mdcode\n" done
echo "Failed" && return 0
fi
if inprogress_callstack=`echo "$subworkflows_text" | grep -F '|InProgress|'`; then if inprogress_callstack=`echo "$subworkflows_text" | grep -F '|InProgress|'`; then
# There's some workflow in-progress. It maybe inprogress or blocked. # There's some workflow in-progress. It maybe inprogress or blocked.
# Note that, there may be multiple workflows in "InProgress" state. In this scenario, # Note that, there may be multiple workflows in "InProgress" state. In this scenario,
# the last "InProgress" workflow is the bottom sub-workflow which we're interested in. # the last "InProgress" workflow is the bottom sub-workflow which we're interested in.
# We just check the last sub-workflow, to see if there's any "Blocked" activity. # We just check the last sub-workflow, to see if there's any "Blocked" activity.
[[ -z "$callstack_formatted" ]] && echo2 "API GetJobHierarchy result misinterpreted. No workflow in stat InProgress or PlanError or InternalError. This is an unexpected non-fatal error and I did not catch it. " && return 2 [[ -z "$callstack_in_email" ]] && echo2 "API GetJobHierarchy result misinterpreted. No workflow in stat InProgress. This is an unexpected non-fatal error and I did not catch it. " && return 2
# Remote workflow may have different namespace, so we need to get bottom_subworkflow_namespace. # Remote workflow may have different namespace, so we need to get bottom_subworkflow_namespace.
bottom_subworkflow_id=`echo "$inprogress_callstack" | tail -n 1 | cut -d '|' -f 3` && bottom_subworkflow_id=`echo "$inprogress_callstack" | tail -n 1 | cut -d '|' -f 3` &&
...@@ -234,8 +232,8 @@ function cis_get_job_status () { ...@@ -234,8 +232,8 @@ function cis_get_job_status () {
# I found some activity blocked! Show incident and exit. # I found some activity blocked! Show incident and exit.
icm_link=`echo "$bottom_wf_pagedtasks_apires" | json2table Data/Tasks/Incidents/ExternalLink -p | sed 's/VAL: //g' | tr -d '|'` || icm_link="" icm_link=`echo "$bottom_wf_pagedtasks_apires" | json2table Data/Tasks/Incidents/ExternalLink -p | sed 's/VAL: //g' | tr -d '|'` || icm_link=""
[[ -z $ANTIDOTE_JOBSTAT_MARKDOWN ]] && [[ -z $ANTIDOTE_JOBSTAT_MARKDOWN ]] &&
echo2 -e ">>> Incident detected:\nCallstack: \n$callstack_formatted\nActivity: \n$bottom_wf_activities\nCIS Log: https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid\nICM Link: $icm_link" || echo2 -e ">>> Incident detected:\nCallstack: \n$callstack_in_email\nActivity: \n$bottom_wf_activities\nCIS Log: https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid\nICM Link: $icm_link" ||
echo2 -e "## Incident detected\n\n[View CIS Log](https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid)\n\n### Callstack\n\n$_mdcode\n$callstack_formatted\n$_mdcode\n\n### Activity\n\n$_mdcode\n$bottom_wf_activities\n$_mdcode\n[View ICM Incident]($icm_link)" echo2 -e "## Incident detected\n\n[View CIS Log](https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid)\n\n### Callstack\n\n$_ts\n$callstack_in_email\n$_ts\n\n### Activity\n\n$_ts\n$bottom_wf_activities\n$_ts\n[View ICM Incident]($icm_link)"
echo "Blocked" && return 0 echo "Blocked" && return 0
fi fi
...@@ -357,7 +355,7 @@ function subcmd_xmldownload () { ...@@ -357,7 +355,7 @@ function subcmd_xmldownload () {
} }
# Initialization # Initialization
antidote_version="1.1.12" antidote_version="1.1.12-2"
subcmd="$1" subcmd="$1"
shift shift
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment