mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
s3api: stop at startup when the -s3.config KMS block doesn't load (#13380)
* s3api: stop at startup when the -s3.config KMS block doesn't load A kms block in the -s3.config file that failed to load was only logged, so S3 came up healthy with SSE-KMS off. Every SSE-KMS write and every read of an SSE-KMS object then failed with 500, and nothing at startup pointed at the config. loadS3ApiConfigurationFromFile now returns the KMS error once it has applied the identities, and startup already stops on any error it returns. A SIGHUP reload still applies the identities, so a revoked key stops working, keeps the previous KMS providers and logs the error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: shorten the KMS load-order comment 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>
This commit is contained in:
2 files changed
+18
-4
No files matched your search
@@ -714,10 +714,8 @@ func (iam *IdentityAccessManagement) loadS3ApiConfigurationFromFile(fileName str
|
||||
return err
|
||||
}
|
||||
|
||||
// Initialize KMS if configuration contains KMS settings
|
||||
if err := iam.initializeKMSFromConfig(content); err != nil {
|
||||
glog.Errorf("KMS initialization failed: %v", err)
|
||||
}
|
||||
// The identities still apply when the KMS block fails, so a reload can revoke access.
|
||||
kmsErr := iam.initializeKMSFromConfig(content)
|
||||
|
||||
// fromStaticFile=true: this file is the source of truth for its static
|
||||
// identities, so a reload overwrites them (e.g. a rotated secretKey).
|
||||
@@ -731,6 +729,9 @@ func (iam *IdentityAccessManagement) loadS3ApiConfigurationFromFile(fileName str
|
||||
// later dynamic merges.
|
||||
iam.markStaticIdentities(config)
|
||||
iam.updateCredentialManagerStaticIdentities()
|
||||
if kmsErr != nil {
|
||||
return fmt.Errorf("load KMS: %w", kmsErr)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,19 @@ func TestIdentitiesThatDontParseLeaveKMSAlone(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestKMSThatDoesntLoadFailsTheFileAfterItsIdentities(t *testing.T) {
|
||||
resetKMS(t)
|
||||
s3a := newTestS3ApiServerWithMemoryIAM(t, []*iam_pb.Identity{})
|
||||
|
||||
err := s3a.iam.loadS3ApiConfigurationFromFile(writeTempIamConfig(t, `{"kms": {"default_provider": "missing"}, "identities": [{"name": "a", "credentials": [{"accessKey": "AKIAKMSFAILED", "secretKey": "c2VjcmV0"}]}]}`))
|
||||
if err == nil {
|
||||
t.Fatal("a kms section that doesn't load was reported as loaded")
|
||||
}
|
||||
if _, _, found := s3a.iam.lookupByAccessKey("AKIAKMSFAILED"); !found {
|
||||
t.Fatal("a kms section that doesn't load held back the identities")
|
||||
}
|
||||
}
|
||||
|
||||
func TestKMSConfigWithANumberOutOfRangeKeepsItOutOfTheError(t *testing.T) {
|
||||
resetKMS(t)
|
||||
iam := &IdentityAccessManagement{}
|
||||
|
||||
Reference in new issue
Block a user