Store bucket created time as a metadata (#9465)

Fixes #9459
This commit is contained in:
Bala FA
2020-05-01 16:53:14 +00:00
committed by GitHub
parent 086be07bf5
commit 83ccae6c8b
5 changed files with 499 additions and 53 deletions
+8 -10
View File
@@ -376,22 +376,20 @@ func checkPutObjectLockAllowed(ctx context.Context, r *http.Request, bucket, obj
func initBucketObjectLockConfig(buckets []BucketInfo, objAPI ObjectLayer) error {
for _, bucket := range buckets {
ctx := logger.SetReqInfo(GlobalContext, &logger.ReqInfo{BucketName: bucket.Name})
configFile := path.Join(bucketConfigPrefix, bucket.Name, bucketObjectLockEnabledConfigFile)
bucketObjLockData, err := readConfig(ctx, objAPI, configFile)
meta, err := loadBucketMetadata(ctx, objAPI, bucket.Name)
if err != nil {
if errors.Is(err, errConfigNotFound) {
continue
if err != errMetaDataConverted {
return err
}
return err
}
if string(bucketObjLockData) != bucketObjectLockEnabledConfig {
// this should never happen
logger.LogIf(ctx, objectlock.ErrMalformedBucketObjectConfig)
meta.Created = bucket.Created
logger.LogIf(ctx, meta.save(ctx, objAPI))
}
if !meta.LockEnabled {
continue
}
configFile = path.Join(bucketConfigPrefix, bucket.Name, objectLockConfig)
configFile := path.Join(bucketConfigPrefix, bucket.Name, objectLockConfig)
configData, err := readConfig(ctx, objAPI, configFile)
if err != nil {
if errors.Is(err, errConfigNotFound) {