Skip to content

Commit e989f14

Browse files
committed
Merge remote-tracking branch 'origin/improvement/BB-728/filter-out-internal-buckets' into w/9.1/improvement/BB-728/filter-out-internal-buckets
2 parents 1e99713 + 03838a1 commit e989f14

File tree

5 files changed

+65
-4
lines changed

5 files changed

+65
-4
lines changed

extensions/notification/NotificationQueuePopulator.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const assert = require('assert');
22
const util = require('util');
33

44
const { isMasterKey } = require('arsenal').versioning;
5-
const { usersBucket, mpuBucketPrefix, supportedNotificationEvents } = require('arsenal').constants;
5+
const { mpuBucketPrefix, supportedNotificationEvents } = require('arsenal').constants;
66
const VID_SEPERATOR = require('arsenal').versioning.VersioningConstants.VersionId.Separator;
77
const configUtil = require('./utils/config');
88
const safeJsonParse = require('./utils/safeJsonParse');
@@ -332,8 +332,13 @@ class NotificationQueuePopulator extends QueuePopulatorExtension {
332332
this.log.error('could not parse log entry', { value, error });
333333
return cb();
334334
}
335-
// ignore bucket op, mpu's or if the entry has no bucket
336-
if (!bucket || bucket === usersBucket || (key && key.startsWith(mpuBucketPrefix))) {
335+
// ignore mpu's or if the entry has no bucket
336+
if (!bucket || (key && key.startsWith(mpuBucketPrefix))) {
337+
return cb();
338+
}
339+
// ignore internal buckets
340+
if (bucket.includes('..')) {
341+
this.log.trace('skipping internal bucket entry', { bucket });
337342
return cb();
338343
}
339344
// bucket notification configuration updates

extensions/replication/ReplicationQueuePopulator.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ class ReplicationQueuePopulator extends QueuePopulatorExtension {
1818
// bucket updates have no key in raft log
1919
return undefined;
2020
}
21+
// users..bucket has a special role for "echo mode"
2122
if (entry.bucket === usersBucket) {
2223
return this._filterBucketOp(entry);
2324
}
25+
// internal buckets (other than users..bucket) are ignored
26+
if (entry.bucket.includes('..')) {
27+
return undefined;
28+
}
2429
return this._filterKeyOp(entry);
2530
}
2631

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backbeat",
3-
"version": "9.1.2",
3+
"version": "9.1.3",
44
"description": "Asynchronous queue and job manager",
55
"main": "index.js",
66
"scripts": {

tests/unit/notification/NotificationQueuePopulator.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,26 @@ describe('NotificationQueuePopulator ::', () => {
404404
});
405405
});
406406

407+
it('should ignore internal bucket operations', done => {
408+
const processObjectEntryStub = sinon.stub(notificationQueuePopulator, '_processObjectEntry');
409+
const processBucketEntryStub = sinon.stub(notificationQueuePopulator, '_processBucketEntry');
410+
const entry = {
411+
bucket: 'internal..backupIndex',
412+
key: 'example-key',
413+
type: 'put',
414+
value: '{}',
415+
overheadFields: {
416+
opTimestamp: new Date().toISOString(),
417+
},
418+
};
419+
notificationQueuePopulator.filterAsync(entry, err => {
420+
assert.ifError(err);
421+
assert(processObjectEntryStub.notCalled);
422+
assert(processBucketEntryStub.notCalled);
423+
return done();
424+
});
425+
});
426+
407427
it('should ignore mpu bucket operations', done => {
408428
const processObjectEntryStub = sinon.stub(notificationQueuePopulator, '_processObjectEntry');
409429
const processBucketEntryStub = sinon.stub(notificationQueuePopulator, '_processBucketEntry');

tests/unit/replication/ReplicationQueuePopulator.spec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,4 +325,35 @@ describe('replication queue populator', () => {
325325
const publishedMessage = rqp.getState();
326326
assert(!publishedMessage.key);
327327
});
328+
329+
it('should ignore internal buckets except users..bucket', () => {
330+
const entry = {
331+
bucket: 'internal..backupIndex',
332+
key: 'key',
333+
value: '{}',
334+
type: 'put',
335+
logReader: {
336+
getMetricLabels: () => {},
337+
},
338+
};
339+
rqp.filter(entry);
340+
const publishedMessage = rqp.getState();
341+
assert.deepStrictEqual(publishedMessage, {});
342+
});
343+
344+
it('should not ignore users..bucket', () => {
345+
const entry = {
346+
bucket: 'users..bucket',
347+
type: 'put',
348+
key: 'owner..|..bucket',
349+
value: '{}',
350+
logReader: {
351+
getMetricLabels: () => {},
352+
},
353+
};
354+
rqp.filter(entry);
355+
const publishedMessage = rqp.getState();
356+
assert(publishedMessage.key);
357+
assert.strictEqual(decodeURIComponent(publishedMessage.key), 'users..bucket');
358+
});
328359
});

0 commit comments

Comments
 (0)