Skip to content

Extend Load Balancer creation waiter to look for errors in Errors field #354

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

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions services/loadbalancer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.9.3 (2024-03-19)

- Update Load Balancer creation waiter to check for errors the instance `Errors` field and, if some are found, return even if the status is still `STATUS_PENDING`

## v0.9.2 (2024-02-28)

- Update `core` to [`v0.10.0`](../../core/CHANGELOG.md#v0100-2024-02-27)
Expand Down
10 changes: 10 additions & 0 deletions services/loadbalancer/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"strings"
"time"

"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
Expand Down Expand Up @@ -46,6 +47,15 @@ func CreateLoadBalancerWaitHandler(ctx context.Context, a APIClientInterface, pr
if s == nil || s.Name == nil || *s.Name != instanceName || s.Status == nil {
return false, nil, nil
}

if s.Errors != nil && len(*s.Errors) != 0 {
errors := make([]string, len(*s.Errors))
for _, err := range *s.Errors {
errors = append(errors, fmt.Sprintf("%s: %s", *err.Type, *err.Description))
}
return true, s, fmt.Errorf("create failed for instance with name %s, got errors: %s", instanceName, strings.Join(errors, ";"))
}

switch *s.Status {
case InstanceStatusReady:
return true, s, nil
Expand Down