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

chore: Add retryable error to cloud provider #1164

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
27 changes: 25 additions & 2 deletions pkg/cloudprovider/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ func IsNodeClaimNotFoundError(err error) bool {
if err == nil {
return false
}
var mnfErr *NodeClaimNotFoundError
return errors.As(err, &mnfErr)
var ncnfErr *NodeClaimNotFoundError
return errors.As(err, &ncnfErr)
}

func IgnoreNodeClaimNotFoundError(err error) error {
Expand Down Expand Up @@ -268,3 +268,26 @@ func IgnoreNodeClassNotReadyError(err error) error {
}
return err
}

// RetryableError is an error type returned by CloudProviders when the action emitting the error has to be retried
type RetryableError struct {
error
}

func NewRetryableError(err error) *RetryableError {
return &RetryableError{
error: err,
}
}

func (e *RetryableError) Error() string {
return fmt.Sprintf("retryable error, %s", e.error)
}

func IsRetryableError(err error) bool {
if err == nil {
return false
}
var retryableError *RetryableError
return errors.As(err, &retryableError)
}
2 changes: 1 addition & 1 deletion pkg/controllers/nodeclaim/termination/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c *Controller) Finalize(ctx context.Context, nodeClaim *v1beta1.NodeClaim)
return reconcile.Result{}, nil
}
if nodeClaim.Status.ProviderID != "" {
if err = c.cloudProvider.Delete(ctx, nodeClaim); cloudprovider.IgnoreNodeClaimNotFoundError(err) != nil {
if err = c.cloudProvider.Delete(ctx, nodeClaim); cloudprovider.IgnoreNodeClaimNotFoundError(err) != nil || cloudprovider.IsRetryableError(err) {
jonathan-innis marked this conversation as resolved.
Show resolved Hide resolved
return reconcile.Result{}, fmt.Errorf("terminating cloudprovider instance, %w", err)
}
}
Expand Down
Loading