relax validation when loading lifecycle document from the backend (#9612)

This commit is contained in:
Anis Elleuch
2020-05-18 16:33:43 +01:00
committed by GitHub
parent de9b391db3
commit 96009975d6
7 changed files with 61 additions and 31 deletions

View File

@@ -72,6 +72,12 @@ func (api objectAPIHandlers) PutBucketLifecycleHandler(w http.ResponseWriter, r
return
}
// Validate the received bucket policy document
if err = bucketLifecycle.Validate(); err != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r))
return
}
if err = objAPI.SetBucketLifecycle(ctx, bucket, bucketLifecycle); err != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r))
return

View File

@@ -23,6 +23,7 @@ import (
"path"
"sync"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/bucket/lifecycle"
)
@@ -148,9 +149,15 @@ func (sys *LifecycleSys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
return err
}
// Do not load the lifecycle configuration if it is not valid
err = config.Validate()
if err != nil {
logger.LogIf(context.Background(), err)
continue
}
sys.Set(bucket.Name, config)
}
return nil
}