Skip to content

Commit

Permalink
Merge pull request #54 from safesoftware/fix-healthcheck-503-message
Browse files Browse the repository at this point in the history
Update error handling of 503 in healthcheck with no message json.
  • Loading branch information
garnold54 authored Apr 9, 2024
2 parents eb5e485 + 534a690 commit 891cee9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func healthcheckRun(f *healthcheckFlags) func(cmd *cobra.Command, args []string)
response, err := client.Do(&request)
if err != nil {
return err
} else if response.StatusCode != 200 && response.StatusCode != 503 {
} else if response.StatusCode != http.StatusOK && response.StatusCode != http.StatusServiceUnavailable {
return errors.New(response.Status)
}

Expand All @@ -148,7 +148,14 @@ func healthcheckRun(f *healthcheckFlags) func(cmd *cobra.Command, args []string)

var resultV4 HealthcheckV4
if err := json.Unmarshal(responseData, &resultV4); err != nil {
return err
// if we fail to unmarshal, it is likely that the server is returning a 503, but not from FME Flow
// return the raw status code in this case
if response.StatusCode != http.StatusOK {
return errors.New(response.Status)
} else {
// if we get here, we failed to unmarshal despite the status code being 200
return err
}
}
if f.outputType == "table" {
t := createTableWithDefaultColumns(resultV4)
Expand Down

0 comments on commit 891cee9

Please sign in to comment.