Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#1432 from shiftstack/gophercloud-e…
Browse files Browse the repository at this point in the history
…rrors

🌱Be more robust when checking gophercloud errors in IsNotFound
  • Loading branch information
k8s-ci-robot authored Jan 4, 2023
2 parents 4526db5 + 8e4cf26 commit 6af7e01
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/utils/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ func IsRetryable(err error) bool {
}

func IsNotFound(err error) bool {
// Gophercloud is not consistent in how it returns 404 errors. Sometimes
// it returns a pointer to the error, sometimes it returns the error
// directly.
// Some discussion here: https://github.com/gophercloud/gophercloud/issues/2279
var errDefault404 gophercloud.ErrDefault404
if errors.As(err, &errDefault404) {
return true
}

var errResourceNotFound gophercloud.ErrResourceNotFound
if errors.As(err, &errResourceNotFound) {
var pErrDefault404 *gophercloud.ErrDefault404
var errNotFound gophercloud.ErrResourceNotFound
var pErrNotFound *gophercloud.ErrResourceNotFound
if errors.As(err, &errDefault404) || errors.As(err, &pErrDefault404) || errors.As(err, &errNotFound) || errors.As(err, &pErrNotFound) {
return true
}

Expand Down

0 comments on commit 6af7e01

Please sign in to comment.