Files
seaweedfs/weed/kms/aws/aws_kms_test.go
T
adb07ee3ce s3api: answer GET with the KMS error when the KMS won't decrypt (#13432)
* s3api: answer GET with the KMS error when the KMS won't decrypt

A GET of an SSE-KMS object whose key the KMS no longer holds, or refuses
to use, returned 500 InternalError, which clients retry. PUT and
CopyObject already answer the same KMS errors with their S3 codes, like
KMS.NotFoundException. GET now does too, on the full, per-chunk key,
range and directory content paths. The per-chunk key path wrapped the
decrypt error with %v, which dropped the KMS error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* kms: report a provider outage as an internal failure

GET now answers a KMS error with its S3 code, so a provider outage that
the converters tagged as a key error turned a retryable read into a 400
that blames the key. OpenBao and Azure 5xx answers and GCP Unavailable
or DeadlineExceeded matched the "not found" or "unavailable" substrings,
and AWS KeyUnavailableException is retryable per the KMS API. All of
these now map to KMSInternalException, which S3 answers as 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-12-05 11:08:03 -08:00

27 lines
652 B
Go

package aws
import (
"testing"
"github.com/aws/aws-sdk-go/aws/awserr"
seaweedkms "github.com/seaweedfs/seaweedfs/weed/kms"
)
func TestRetryableErrorIsAnInternalFailure(t *testing.T) {
p := &AWSKMSProvider{}
for _, tc := range []struct {
code string
want string
}{
{"KeyUnavailableException", seaweedkms.ErrCodeKMSInternalFailure},
{"DisabledException", seaweedkms.ErrCodeKeyUnavailable},
{"NotFoundException", seaweedkms.ErrCodeNotFoundException},
} {
got := p.convertAWSError(awserr.New(tc.code, "", nil), "k").(*seaweedkms.KMSError).Code
if got != tc.want {
t.Errorf("%s: got %s, want %s", tc.code, got, tc.want)
}
}
}