mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-24 08:15:52 +00:00
ignore error when deleting non-existing resources
This commit is contained in:
+14
-5
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
@@ -157,11 +158,9 @@ func (a *AwsS3Client) DeleteBucket(ctx context.Context) error {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var ae smithy.APIError
|
var ae smithy.APIError
|
||||||
var nfe *s3types.NoSuchBucket
|
errorCodes := []string{"BucketNotEmpty", "NoSuchBucket"}
|
||||||
if errors.As(err, &ae) && ae.ErrorCode() == "BucketNotEmpty" {
|
if errors.As(err, &ae) && slices.Contains(errorCodes, ae.ErrorCode()) {
|
||||||
log.Println("skipped error", err)
|
log.Println("Deletion skipped: ", err)
|
||||||
}
|
|
||||||
if errors.As(err, &nfe) {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@@ -180,6 +179,11 @@ func (a *AwsS3Client) DeleteObjects(ctx context.Context, objectKeys []string) er
|
|||||||
Delete: &s3types.Delete{Objects: objectIds},
|
Delete: &s3types.Delete{Objects: objectIds},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var ae smithy.APIError
|
||||||
|
if errors.As(err, &ae) && ae.ErrorCode() == "NoSuchBucket" {
|
||||||
|
log.Println("Deletion skipped: the bucket does not exist.", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@@ -219,6 +223,11 @@ func (a *AwsIamClient) DeleteOIDCProvider(ctx context.Context, accountId, issuer
|
|||||||
OpenIDConnectProviderArn: aws.String(fmt.Sprintf("arn:aws:iam::%s:oidc-provider/%s", accountId, issuerHostPath)),
|
OpenIDConnectProviderArn: aws.String(fmt.Sprintf("arn:aws:iam::%s:oidc-provider/%s", accountId, issuerHostPath)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var ae smithy.APIError
|
||||||
|
if errors.As(err, &ae) && ae.ErrorCode() == "NoSuchEntity" {
|
||||||
|
log.Println("Deletion skipped: ", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user