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

security-group show: fix empty response if an API endpoint is misbehaving #660

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

- instance update: fixing no err check after creating client #657
- fix(error): Improve error message on snapshot creation (#655)
- security-group show: fix empty response if an API endpoint is misbehaving #660

## 1.82.0

Expand Down
15 changes: 11 additions & 4 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/rand"
"encoding/base64"
"errors"
"fmt"
"net"
"strconv"
Expand Down Expand Up @@ -49,15 +50,21 @@ func GetInstancesInSecurityGroup(ctx context.Context, client *v2.Client, securit

instances, err := client.ListInstances(ctx, zone)
if err != nil {
return err
if !errors.Is(err, exoapi.ErrNotFound) {
return err
}
} else {
allInstances = append(allInstances, instances...)
}

allInstances = append(allInstances, instances...)

return nil
})
if err != nil {
return nil, err
if allInstances == nil {
return nil, err
} else {
fmt.Printf("error while listing instances in security group: %s", err)
}
}

var instancesInSG []*v2.Instance
Expand Down
Loading