Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update error handling of 503 in healthcheck with no message json. #54

Merged
merged 1 commit into from
Apr 9, 2024
Merged
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
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
Loading