Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions extensions/gc/GarbageCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,11 @@ class GarbageCollector extends EventEmitter {
}

/**
* Start kafka consumer. Emits a 'ready' event when
* consumer is ready.
*
* @return {undefined}
* Build the options of the garbage collector topic consumer
* @return {Object} consumer options
*/
start() {
let consumerReady = false;
this._consumer = new BackbeatConsumer({
_getConsumerOptions() {
return {
kafka: {
hosts: this._kafkaConfig.hosts,
site: this._kafkaConfig.site,
Expand All @@ -143,7 +140,19 @@ class GarbageCollector extends EventEmitter {
// sent to the gc don't have a key anyways)
orderByFunc: null,
queueProcessor: this.processKafkaEntry.bind(this),
});
fromOffset: 'earliest',
};
}

/**
* Start kafka consumer. Emits a 'ready' event when
* consumer is ready.
*
* @return {undefined}
*/
start() {
let consumerReady = false;
this._consumer = new BackbeatConsumer(this._getConsumerOptions());
this._consumer.on('error', () => {
if (!consumerReady) {
this._logger.error('garbage collector failed to start the ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class LifecycleObjectTransitionProcessor extends LifecycleObjectProcessor {
getConsumerParams() {
const consumerParams = super.getConsumerParams(this._lcConfig.transitionTasksTopic);

consumerParams[this._lcConfig.transitionTasksTopic].fromOffset = 'earliest';

const locations = require('../../../conf/locationConfig.json') || {};

this._lcConfig.coldStorageTopics.forEach(topic => {
Expand Down Expand Up @@ -133,6 +135,7 @@ class LifecycleObjectTransitionProcessor extends LifecycleObjectProcessor {
maxQueued: this._processConfig.maxQueued,
queueProcessor: this.processColdStorageStatusEntry.bind(this),
circuitBreaker,
fromOffset: 'earliest',
};
});

Expand Down
4 changes: 4 additions & 0 deletions tests/unit/gc/GarbageCollector.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ describe('garbage collector', function garbageCollector() {
after(() => {
httpServer.close();
});
it('should consume the gc topic from the earliest offset', () => {
assert.strictEqual(gc._getConsumerOptions().fromOffset, 'earliest');
});

it('should skip unsupported action type', done => {
expectBatchDeleteLocations = null;
const action = ActionQueueEntry.create('foo');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ describe('LifecycleObjectExpirationProcessor', () => {
);
});

it('should not pin fromOffset on the object tasks topic', () => {
const consumerParams = objectProcessor.getConsumerParams();
assert.strictEqual(
consumerParams[config.extensions.lifecycle.objectTasksTopic].fromOffset,
undefined,
);
});

it('should contain object tasks topic in consumer params', () => {
const consumerParams = objectProcessor.getConsumerParams();
assert.deepStrictEqual(Object.keys(consumerParams), [config.extensions.lifecycle.objectTasksTopic]);
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/lifecycle/LifecycleObjectTransitionProcessor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ describe('LifecycleObjectTransitionProcessor', () => {
);
});

it('should consume the transition tasks topic from the earliest offset', () => {
const consumerParams = objectProcessor.getConsumerParams();
assert.strictEqual(
consumerParams[config.extensions.lifecycle.transitionTasksTopic].fromOffset,
'earliest'
);
});

it('should consume the cold status topics from the earliest offset', () => {
const coldTopic = `${config.extensions.lifecycle.coldStorageStatusTopicPrefix}location-dmf-v1`;
const coldProcessor = new LifecycleObjectTransitionProcessor(
config.zookeeper,
config.kafka,
{ ...config.extensions.lifecycle, coldStorageTopics: [coldTopic] },
config.s3,
);
const consumerParams = coldProcessor.getConsumerParams();
assert.strictEqual(consumerParams[coldTopic].fromOffset, 'earliest');
});

it('should contain transition tasks topic in consumer params', () => {
const consumerParams = objectProcessor.getConsumerParams();
assert.deepStrictEqual(Object.keys(consumerParams), [config.extensions.lifecycle.transitionTasksTopic]);
Expand Down
Loading