Skip to content

Commit

Permalink
prefer actual error over context deadline exceeded (#320)
Browse files Browse the repository at this point in the history
* prefer actual error over context deadline exceeded

* update sdk

* mention context deadline exceeded

---------

Co-authored-by: Furkhat Kasymov Genii Uulu <furkhat@cast.ai>
  • Loading branch information
furkhat and Furkhat Kasymov Genii Uulu committed Jun 3, 2024
1 parent 25c75f0 commit e4f6008
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 34 deletions.
6 changes: 6 additions & 0 deletions castai/resource_aks_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package castai

import (
"context"
"errors"
"fmt"
"log"
"time"
Expand Down Expand Up @@ -215,10 +216,15 @@ func updateAKSClusterSettings(ctx context.Context, data *schema.ResourceData, cl

// Retries are required for newly created IAM resources to initialise on Azure side.
b := backoff.WithContext(backoff.WithMaxRetries(backoff.NewConstantBackOff(10*time.Second), 30), ctx)
var lastErr error
if err = backoff.Retry(func() error {
response, err := client.ExternalClusterAPIUpdateClusterWithResponse(ctx, data.Id(), req)
lastErr = err
return sdk.CheckOKResponse(response, err)
}, b); err != nil {
if errors.Is(err, context.DeadlineExceeded) && lastErr != nil {
return fmt.Errorf("updating cluster configuration: %w: %v", err, lastErr)
}
return fmt.Errorf("updating cluster configuration: %w", err)
}

Expand Down
39 changes: 5 additions & 34 deletions castai/sdk/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4f6008

Please sign in to comment.