Compare commits

...

2 Commits

Author SHA1 Message Date
philipyoo 82be4bd3e6 bf: ZENKO-1585 zenko user-metadata header constant
This constant will be used in backbeat and cloudserver as
a user metadata defined header indicating if an object has
been created in a zenko deployment
2019-04-19 17:40:25 -07:00
philipyoo c685c62a5e bf: ZENKO-1718 ingestion mongo putObjectVerCase4
Add a putObjectVerCase to MongoClientInterface for ingestion
use-cases. Remove management of master versions in the
ingestion process and rely on the natural ordering of
objects stored in mongo. Get and Delete operations will
rely on internal MongoClientInterface methods for performing
relevant operations. To do this, we set PHD on master for
each object version ingested.
2019-04-19 15:40:34 -07:00
2 changed files with 55 additions and 1 deletions

View File

@ -112,4 +112,6 @@ module.exports = {
clientsRequireStringKey: { sproxyd: true, cdmi: true },
hasCopyPartBackends: { aws_s3: true, gcp: true },
versioningNotImplBackends: { azure: true, gcp: true },
// user metadata applied on zenko-created objects
zenkoIDHeader: 'x-amz-meta-zenko-instance-id',
};

View File

@ -508,6 +508,55 @@ class MongoClientInterface {
});
}
/*
* In this case the caller provides a versionId and a flag called usePHD.
* This function will save the versionId object as is and will set PHD on
* master. If a user performs any operation to find IsLatest, the PHD flag
* indicates to perform a search on the bucket to find the latest version.
* We rely on the natural ordering of versions for listings. We rely on
* internal MongoClientInterface operations for master version and repairs.
*/
putObjectVerCase4(c, bucketName, objName, objVal, params, log, cb) {
// eslint-disable-next-line
objVal.versionId = params.versionId;
const vObjName = formatVersionKey(objName, params.versionId);
const mst = generatePHDVersion(params.versionId);
return c.bulkWrite([{
updateOne: {
filter: {
_id: vObjName,
},
update: {
$set: {
_id: vObjName,
value: objVal,
},
},
upsert: true,
},
}, {
updateOne: {
filter: {
_id: objName,
},
update: {
_id: objName, value: mst,
},
upsert: true,
},
}], {
ordered: 1,
}, err => {
if (err) {
log.error('putObjectVerCase4: error putting object version', {
error: err.message,
});
return cb(errors.InternalError);
}
return cb(null, `{"versionId": "${objVal.versionId}"}`);
});
}
/*
* Put object when versioning is not enabled
*/
@ -539,9 +588,12 @@ class MongoClientInterface {
} else if (params && params.versionId === '') {
return this.putObjectVerCase2(c, bucketName, objName, objVal,
params, log, cb);
} else if (params && params.versionId) {
} else if (params && params.versionId && !params.usePHD) {
return this.putObjectVerCase3(c, bucketName, objName, objVal,
params, log, cb);
} else if (params && params.versionId && params.usePHD) {
return this.putObjectVerCase4(c, bucketName, objName, objVal,
params, log, cb);
}
return this.putObjectNoVer(c, bucketName, objName, objVal,
params, log, cb);