Skip to content

Commit

Permalink
more user friendly error msgs
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <[email protected]>
  • Loading branch information
jakubdyszkiewicz committed Oct 19, 2020
1 parent f151cc9 commit 3e49ff5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/kuma-dp/pkg/dataplane/envoy/remote_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,17 @@ func (b *remoteBootstrap) requestForBootstrap(url *net_url.URL, cfg kuma_dp.Conf
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
if resp.StatusCode == http.StatusNotFound {
bodyBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrapf(err, "Unable to read the response with status code: %d. Make sure you are using https URL", resp.StatusCode)
}
if resp.StatusCode == http.StatusNotFound && len(bodyBytes) == 0 {
return nil, DpNotFoundErr
}
if resp.StatusCode == http.StatusNotFound && string(bodyBytes) == "404: Page Not Found" { // response body of Go HTTP Server when hit for invalid endpoint
return nil, errors.New("There is no /bootstrap endpoint for provided CP address. Double check if the address passed to the CP has a DP Server port (5678 by default), not HTTP API (5681 by default)")
}
if resp.StatusCode == http.StatusUnprocessableEntity {
bodyBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, errors.Errorf("Unable to read the response with status code: %d", resp.StatusCode)
}
return nil, InvalidRequestErr(string(bodyBytes))
}
return nil, errors.Errorf("unexpected status code: %d", resp.StatusCode)
Expand Down

0 comments on commit 3e49ff5

Please sign in to comment.