diff --git a/cmd/bucket-policy-handlers.go b/cmd/bucket-policy-handlers.go index 6350f1ef3..277ec5da5 100644 --- a/cmd/bucket-policy-handlers.go +++ b/cmd/bucket-policy-handlers.go @@ -86,7 +86,11 @@ func (api objectAPIHandlers) PutBucketPolicyHandler(w http.ResponseWriter, r *ht bucketPolicy, err := policy.ParseConfig(bytes.NewReader(bucketPolicyBytes), bucket) if err != nil { - writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) + writeErrorResponse(ctx, w, APIError{ + Code: "ErrMalformedXML", + HTTPStatusCode: http.StatusBadRequest, + Description: err.Error(), + }, r.URL) return } diff --git a/cmd/kms-handlers.go b/cmd/kms-handlers.go index ba60ca13d..321358ea7 100644 --- a/cmd/kms-handlers.go +++ b/cmd/kms-handlers.go @@ -82,6 +82,11 @@ func (a kmsAPIHandlers) KMSMetricsHandler(w http.ResponseWriter, r *http.Request return } + if _, ok := GlobalKMS.(kms.KeyManager); !ok { + writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrNotImplemented), r.URL) + return + } + metrics, err := GlobalKMS.Metrics(ctx) if err != nil { writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) diff --git a/cmd/metacache-server-pool.go b/cmd/metacache-server-pool.go index 38cbff39e..61402f093 100644 --- a/cmd/metacache-server-pool.go +++ b/cmd/metacache-server-pool.go @@ -316,11 +316,11 @@ func (z *erasureServerPools) listMerged(ctx context.Context, o listPathOptions, } for _, err := range errs { - if err == nil || contextCanceled(ctx) { - allAtEOF = false + if errors.Is(err, io.EOF) { continue } - if err.Error() == io.EOF.Error() { + if err == nil || contextCanceled(ctx) || errors.Is(err, context.Canceled) { + allAtEOF = false continue } logger.LogIf(ctx, err) diff --git a/cmd/metacache-set.go b/cmd/metacache-set.go index cce78e24d..2d804f82e 100644 --- a/cmd/metacache-set.go +++ b/cmd/metacache-set.go @@ -376,7 +376,7 @@ func (r *metacacheReader) filter(o listPathOptions) (entries metaCacheEntriesSor entries.o = append(entries.o, entry) return entries.len() < o.Limit }) - if (err != nil && err.Error() == io.EOF.Error()) || pastPrefix || r.nextEOF() { + if (err != nil && errors.Is(err, io.EOF)) || pastPrefix || r.nextEOF() { return entries, io.EOF } return entries, err @@ -534,7 +534,7 @@ func (er *erasureObjects) streamMetadataParts(ctx context.Context, o listPathOpt // We stopped within the listing, we are done for now... return entries, nil } - if err != nil && err.Error() != io.EOF.Error() { + if err != nil && !errors.Is(err, io.EOF) { switch toObjectErr(err, minioMetaBucket, o.objectPath(partN)).(type) { case ObjectNotFound: retries++ @@ -940,15 +940,6 @@ func listPathRaw(ctx context.Context, opts listPathRawOptions) (err error) { } } w.CloseWithError(werr) - - if werr != io.EOF && werr != nil && - werr.Error() != errFileNotFound.Error() && - werr.Error() != errVolumeNotFound.Error() && - werr.Error() != errDiskNotFound.Error() && - werr.Error() != errUnformattedDisk.Error() && - !errors.Is(werr, context.Canceled) { - logger.LogIf(ctx, werr) - } }() } diff --git a/internal/kms/single-key.go b/internal/kms/single-key.go index bfd8aceca..59f2299d7 100644 --- a/internal/kms/single-key.go +++ b/internal/kms/single-key.go @@ -91,12 +91,15 @@ func (kms secretKey) Stat(context.Context) (Status, error) { }, nil } -func (secretKey) Metrics(ctx context.Context) (kes.Metric, error) { - return kes.Metric{}, errors.New("kms: metrics are not supported") +func (secretKey) Metrics(context.Context) (kes.Metric, error) { + return kes.Metric{}, errors.New("kms: metrics not supported") } -func (secretKey) CreateKey(context.Context, string) error { - return errors.New("kms: creating keys is not supported") +func (kms secretKey) CreateKey(_ context.Context, keyID string) error { + if keyID == kms.keyID { + return nil + } + return fmt.Errorf("kms: creating custom key %q is not supported", keyID) } func (kms secretKey) GenerateKey(_ context.Context, keyID string, context Context) (DEK, error) {