Skip to content

Commit

Permalink
Report owner-id when getting archive info
Browse files Browse the repository at this point in the history
Issue: CLDSRV-545
  • Loading branch information
francoisferrand committed Jul 10, 2024
1 parent 76fa60c commit 6011da1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/api/apiUtils/object/coldStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ function setArchiveInfoHeaders(objMD) {
// Always get the "real" storage class (even when STANDARD) in this case
headers['x-amz-storage-class'] = objMD['x-amz-storage-class'] || objMD.dataStoreName;

// Get the owner-id
headers['x-amz-scal-owner-id'] = objMD['owner-id'];

return headers;
}

Expand Down
8 changes: 7 additions & 1 deletion tests/unit/api/objectHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ describe('objectHead API', () => {
assert.strictEqual(res['x-amz-scal-archive-info'], undefined);
assert.strictEqual(res['x-amz-scal-restore-requested-at'], undefined);
assert.strictEqual(res['x-amz-scal-restore-requested-days'], undefined);
assert.strictEqual(res['x-amz-scal-owner-id'], undefined);
done();
});
});
Expand Down Expand Up @@ -416,13 +417,13 @@ describe('objectHead API', () => {
assert.strictEqual(res['x-amz-scal-restore-requested-at'], undefined);
assert.strictEqual(res['x-amz-scal-restore-completed-at'], undefined);
assert.strictEqual(res['x-amz-scal-restore-will-expire-at'], undefined);
assert.strictEqual(res['x-amz-scal-owner-id'], undefined);
done();
});
});
});
});

// add GetRequest with flag for different kind of objects
it('should report when transition in progress', done => {
const testGetRequest = {
bucketName,
Expand All @@ -439,6 +440,7 @@ describe('objectHead API', () => {
assert.strictEqual(res['x-amz-scal-transition-in-progress'], undefined);
assert.strictEqual(res['x-amz-scal-transition-time'], undefined);
assert.strictEqual(res['x-amz-scal-archive-info'], undefined);
assert.strictEqual(res['x-amz-scal-owner-id'], undefined);
done(err);
});
});
Expand All @@ -464,6 +466,7 @@ describe('objectHead API', () => {
assert.strictEqual(res['x-amz-scal-transition-time'],
new Date(objectCustomMDFields['x-amz-scal-transition-time']).toUTCString());
assert.strictEqual(res['x-amz-scal-archive-info'], undefined);
assert.strictEqual(res['x-amz-scal-owner-id'], mdColdHelper.defaultOwnerId);
done(err);
});
});
Expand All @@ -488,6 +491,7 @@ describe('objectHead API', () => {
assert.strictEqual(res['x-amz-scal-transition-in-progress'], undefined);
assert.strictEqual(res['x-amz-scal-archive-info'], '{"foo":0,"bar":"stuff"}');
assert.strictEqual(res['x-amz-storage-class'], mdColdHelper.defaultLocation);
assert.strictEqual(res['x-amz-scal-owner-id'], mdColdHelper.defaultOwnerId);
done(err);
});
});
Expand Down Expand Up @@ -516,6 +520,7 @@ describe('objectHead API', () => {
assert.strictEqual(res['x-amz-scal-restore-requested-days'],
objectCustomMDFields.archive.restoreRequestedDays);
assert.strictEqual(res['x-amz-storage-class'], mdColdHelper.defaultLocation);
assert.strictEqual(res['x-amz-scal-owner-id'], mdColdHelper.defaultOwnerId);
done(err);
});
});
Expand Down Expand Up @@ -548,6 +553,7 @@ describe('objectHead API', () => {
assert.strictEqual(res['x-amz-scal-restore-will-expire-at'],
new Date(objectCustomMDFields.archive.restoreWillExpireAt).toUTCString());
assert.strictEqual(res['x-amz-storage-class'], mdColdHelper.defaultLocation);
assert.strictEqual(res['x-amz-scal-owner-id'], mdColdHelper.defaultOwnerId);
done(err);
});
});
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/api/utils/metadataMockColdStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ const ObjectMDArchive = require('arsenal').models.ObjectMDArchive;
const BucketInfo = require('arsenal').models.BucketInfo;

const defaultLocation = 'location-dmf-v1';
const defaultOwnerId = '79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be';

const baseMd = {
'owner-display-name': 'accessKey1displayName',
'owner-id': '79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be',
'owner-id': defaultOwnerId,
'content-length': 11,
'content-md5': 'be747eb4b75517bf6b3cf7c5fbb62f3a',
'content-language': '',
Expand Down Expand Up @@ -178,4 +179,5 @@ module.exports = {
getTransitionInProgressMD,
putBucketMock,
defaultLocation,
defaultOwnerId,
};

0 comments on commit 6011da1

Please sign in to comment.