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

bug fix: incorrect getjobhierarchy_apires interpret is causing failure on job...

bug fix: incorrect getjobhierarchy_apires interpret is causing failure on job Finish or NotStarted state
parent 9af87c74
No related branches found
No related tags found
No related merge requests found
......@@ -188,12 +188,13 @@ function cis_get_job_status () {
# Returns job summary in stderr, in plain text or markdown format.
jobid="$1"
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" || return $?
callstack_formatted=`echo "$getjobhierarchy_apires" | json2table DisplayName,Id,DisplayStatus | grep -E '( InProgress )|( PlanError )'` || ! echo2 "API GetJobHierarchy failed" || 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 )'` # Ignore failure because it's only useful in InProgress and PlanError state.
_mdcode='```'
if planerror_callstack=`echo "$subworkflows_text" | grep -F '|PlanError|'`; then
# RemoteJob may have PlanError in subworkflow. The top-level workflow is still InProgress but bottom workflow got PlanError.
[[ -z "$callstack_formatted" ]] && echo2 "API GetJobHierarchy result misinterpreted. No workflow in stat InProgress or PlanError. This is an unexpected non-fatal error and I did not catch it. " && return 2
[[ ! -v ANTIDOTE_JOBSTAT_MARKDOWN ]] &&
echo2 -e ">>> CIS reported PlanError:\nCallstack: \n$callstack_formatted\nCIS Log: https://beta-cps.trafficmanager.net/Public/$cis_namespace/JobDetails/$jobid" ||
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"
......@@ -205,6 +206,8 @@ function cis_get_job_status () {
# 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.
[[ -z "$callstack_formatted" ]] && echo2 "API GetJobHierarchy result misinterpreted. No workflow in stat InProgress or PlanError. 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.
bottom_subworkflow_id=`echo "$inprogress_callstack" | tail -n 1 | cut -d '|' -f 3` &&
bottom_subworkflow_namespace=`echo "$inprogress_callstack" | tail -n 1 | cut -d '|' -f 4` &&
......@@ -315,7 +318,7 @@ function subcmd_listver () {
}
# Initialization
antidote_version="1.1.06"
antidote_version="1.1.07"
subcmd="$1"
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