Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

orchestrator-client: return raw JSON for api call on error #1166

Merged
merged 4 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions go/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3081,11 +3081,10 @@ func (this *HttpAPI) gracefulMasterTakeover(params martini.Params, r render.Rend
Respond(r, &APIResponse{Code: ERROR, Message: err.Error(), Details: topologyRecovery})
return
}
if topologyRecovery.SuccessorKey == nil {
if topologyRecovery == nil || topologyRecovery.SuccessorKey == nil {
Respond(r, &APIResponse{Code: ERROR, Message: "graceful-master-takeover: no successor promoted", Details: topologyRecovery})
return
}

Respond(r, &APIResponse{Code: OK, Message: "graceful-master-takeover: successor promoted", Details: topologyRecovery})
}

Expand Down
2 changes: 1 addition & 1 deletion go/inst/instance_topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ func Repoint(instanceKey *InstanceKey, masterKey *InstanceKey, gtidHint Operatio
masterIsAccessible := (err == nil)
if !masterIsAccessible {
master, _, err = ReadInstance(masterKey)
if err != nil {
if master == nil || err != nil {
return instance, err
}
}
Expand Down
11 changes: 8 additions & 3 deletions resources/bin/orchestrator-client
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ function api {
local curl_auth_params="$(get_curl_auth_params)"

path="$1"
raw_output="${2:-}"

uri="$leader_api/$path"
# echo $uri
Expand Down Expand Up @@ -281,8 +282,12 @@ function api {
fi
api_details=$(echo $api_response | jq '.Details')
if echo $api_response | jq -r '.Code' | grep -q "ERROR" ; then
echo $api_response | jq -r '.Message' | tr -d "'" | xargs >&2 echo
[ "$api_details" != "null" ] && echo $api_details
if [ -n "$raw_output" ] ; then
echo $api_response
else
echo $api_response | jq -r '.Message' | tr -d "'" | xargs >&2 echo
[ "$api_details" != "null" ] && echo $api_details
fi
exit 1
fi
}
Expand Down Expand Up @@ -329,7 +334,7 @@ function which_api {

function api_call {
assert_nonempty "path" "$api_path"
api "$api_path"
api "$api_path" "true"
print_response
}

Expand Down