From 25f3a47b81f052f569817855a5d869fae51dde12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9a=20Grondier?= Date: Mon, 6 Jan 2025 16:34:19 +0100 Subject: [PATCH 1/2] security-group show: fix empty response if an API endpoint is misbehaving --- utils/utils.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 0292bd68..6c500aad 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -4,6 +4,7 @@ import ( "context" "crypto/rand" "encoding/base64" + "errors" "fmt" "net" "strconv" @@ -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 From a34ee63db32e20cdeae61d8a045110791de46cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9a=20Grondier?= Date: Thu, 9 Jan 2025 10:23:31 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbfcf0e2..cf72f49c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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