Skip to content

Improvement/bb 514 handle lifecycle rules #2548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2024
Merged
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
5 changes: 5 additions & 0 deletions extensions/lifecycle/LifecycleConfigValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const {
retryParamsJoi,
} = require('../../lib/config/configItems.joi');

const { supportedLifecycleRules } = require('../../lib/constants');

const joiSchema = joi.object({
zookeeperPath: joi.string().required(),
bucketTasksTopic: joi.string().required(),
Expand Down Expand Up @@ -73,6 +75,9 @@ const joiSchema = joi.object({
coldStorageRestoreAdjustTopicPrefix: joi.string().default('cold-restore-adjust-req-'),
coldStorageGCTopicPrefix: joi.string().default('cold-gc-req-'),
coldStorageStatusTopicPrefix: joi.string().default('cold-status-'),
supportedLifecycleRules: joi.array().items(
joi.string().valid(...supportedLifecycleRules)
).default(supportedLifecycleRules),
});

function configValidator(backbeatConfig, extConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ClientManager = require('../../../lib/clients/ClientManager');
const { authTypeAssumeRole } = require('../../../lib/constants');
const LocationStatusStream = require('../../utils/LocationStatusStream');
const {
getFormattedSupportedLifecycleRules,
formatSupportedLifecycleRules,
isExpirationRule
} = require('../util/rules');
const {
Expand Down Expand Up @@ -88,7 +88,7 @@ class LifecycleBucketProcessor {
this._producer = null;
this._kafkaBacklogMetrics = null;

this._supportedRules = getFormattedSupportedLifecycleRules();
this._supportedRules = formatSupportedLifecycleRules(lcConfig);

this._producerReady = false;
this._consumerReady = false;
Expand Down Expand Up @@ -186,6 +186,7 @@ class LifecycleBucketProcessor {
lcOptions: this._lcOptions,
circuitBreakers: this._circuitBreakers,
log: this._log,
supportedRules: this._lcConfig.supportedLifecycleRules,
};
}

Expand Down
5 changes: 2 additions & 3 deletions extensions/lifecycle/tasks/LifecycleTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const async = require('async');
const { errors, versioning } = require('arsenal');
const { ObjectMD } = require('arsenal').models;
const { supportedLifecycleRules } = require('arsenal').constants;
const {
LifecycleDateTime,
LifecycleUtils,
Expand Down Expand Up @@ -97,10 +96,10 @@ class LifecycleTask extends BackbeatTask {
});

this._lifecycleUtils = new LifecycleUtils(
supportedLifecycleRules,
this.supportedRules,
this._lifecycleDateTime
);
this._supportedRules = supportedLifecycleRules;
this._supportedRules = this.supportedRules;
this._totalRetries = 0;
}

Expand Down
10 changes: 5 additions & 5 deletions extensions/lifecycle/util/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { RulesReducer } = require('./RulesReducer');
const { lifecycleListing: { NON_CURRENT_TYPE, CURRENT_TYPE, ORPHAN_DM_TYPE } } = require('../../../lib/constants');

const { s3middleware } = require('arsenal');
const { supportedLifecycleRules } = require('arsenal').constants;
const { scaleMsPerDay } = s3middleware.objectUtils;

// Default max AWS limit is 1000 for both list objects and list object versions
Expand Down Expand Up @@ -198,11 +197,12 @@ function rulesToParams(versioningStatus, currentDate, bucketLCRules, bucketData,
/**
* Formats the array of supported lifecycle rules in Arsenal so that
* they correspond to how they are written in the lifecycle configuration.
* @param {string[]} supportedLifecycleRules list of supported lifecycle rules
* @param {Object} lcConfig - Lifecycle configuration object
* @param {string[]} lcConfig.supportedLifecycleRules - List of supported lifecycle rules
* @returns {string[]} formatted supported lifecycle rules
*/
function getFormattedSupportedLifecycleRules() {
return supportedLifecycleRules.map(rule => {
function formatSupportedLifecycleRules(lcConfig) {
return lcConfig.supportedLifecycleRules.map(rule => {
if (rule === 'noncurrentVersionTransition') {
return 'NoncurrentVersionTransitions';
}
Expand All @@ -228,7 +228,7 @@ function rulesSupportTransition(lcRules) {

module.exports = {
rulesToParams,
getFormattedSupportedLifecycleRules,
formatSupportedLifecycleRules,
isExpirationRule,
rulesSupportTransition,
};
3 changes: 2 additions & 1 deletion lib/config/configItems.joi.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const qpKafkaJoi = kafkaJoi.append({
replication: extensionKafkaJoi,
});


module.exports = {
hostPortJoi,
transportJoi,
Expand All @@ -172,5 +173,5 @@ module.exports = {
probeServerPerSite,
stsConfigJoi,
mongoJoi,
qpKafkaJoi,
qpKafkaJoi
};
9 changes: 8 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ const constants = {
},
],
},
}
},
supportedLifecycleRules: [
'expiration',
'noncurrentVersionExpiration',
'abortIncompleteMultipartUpload',
'transitions',
'noncurrentVersionTransition'
]
};

module.exports = constants;
7 changes: 7 additions & 0 deletions tests/functional/lifecycle/LifecycleTaskV2-versioned.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ describe('LifecycleTaskV2 with bucket versioned', () => {
circuitBreakers: {
tripped: () => false,
},
supportedRules: [
'expiration',
'noncurrentVersionExpiration',
'abortIncompleteMultipartUpload',
'transitions',
'noncurrentVersionTransition'
],
}),
};
lifecycleTask = new LifecycleTaskV2(lp);
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/lifecycle/LifecycleTaskV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ describe('LifecycleTaskV2 with bucket non-versioned', () => {
circuitBreakers: {
tripped: () => false,
},
supportedRules: [
'expiration',
'noncurrentVersionExpiration',
'abortIncompleteMultipartUpload',
'transitions',
'noncurrentVersionTransition'
],
}),
};
lifecycleTask = new LifecycleTaskV2(lp);
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/lifecycle/configObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ const lcConfig = {
enabled: true,
},
},
supportedLifecycleRules: [
'expiration',
'noncurrentVersionExpiration',
'abortIncompleteMultipartUpload',
'transitions',
'noncurrentVersionTransition'
]
};

const repConfig = {
Expand Down
Loading