fix tests

This commit is contained in:
Jesse Haka 2021-11-16 20:11:18 +02:00
parent c7e0585e3a
commit 508a590116
2 changed files with 5 additions and 4 deletions

View File

@ -74,9 +74,6 @@ const (
ResourceTypeSubnet = "subnets"
)
// ErrNotFound is used to inform that the object is not found
var ErrNotFound = "Resource not found"
// readBackoff is the backoff strategy for openstack read retries.
var readBackoff = wait.Backoff{
Duration: time.Second,
@ -793,6 +790,10 @@ func isNotFound(err error) bool {
return true
}
if _, ok := err.(gophercloud.ErrResourceNotFound); ok {
return true
}
if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
if errCode.Actual == http.StatusNotFound {
return true

View File

@ -33,7 +33,7 @@ func getKeypair(c OpenstackCloud, name string) (*keypairs.KeyPair, error) {
done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) {
rs, err := keypairs.Get(c.ComputeClient(), name, nil).Extract()
if err != nil {
if err.Error() == ErrNotFound {
if isNotFound(err) {
return true, nil
}
return false, fmt.Errorf("error listing keypair: %v", err)