Use strongerrors in provider implementations. (#403)

This ensures that we can catch certain types of errors from providers
and handle accordingly in the core. There is still more to do here to
improve that but this resolves an immediate need to know why a Delete
failed.

vic provider was not updated since I could not figure out where to get
this information.
This commit is contained in:
Brian Goff
2018-11-07 16:02:48 -08:00
committed by Robbie Zhang
parent 1d76b1341e
commit cd42fdd7b8
15 changed files with 210 additions and 20 deletions

View File

@@ -29,6 +29,7 @@ import (
"time"
"github.com/cenkalti/backoff"
"github.com/cpuguy83/strongerrors"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/remotecommand"
@@ -283,7 +284,12 @@ func (p *BrokerProvider) doRequest(method string, urlPath *url.URL, body []byte,
defer response.Body.Close()
if response.StatusCode < 200 || response.StatusCode > 299 {
return nil, errors.New(response.Status)
switch response.StatusCode {
case http.StatusNotFound:
return nil, strongerrors.NotFound(errors.New(response.Status))
default:
return nil, errors.New(response.Status)
}
}
// read response body if asked to