diff --git a/extensions/lifecycle/LifecycleConfigValidator.js b/extensions/lifecycle/LifecycleConfigValidator.js index 100c56b6c..680e46c97 100644 --- a/extensions/lifecycle/LifecycleConfigValidator.js +++ b/extensions/lifecycle/LifecycleConfigValidator.js @@ -5,9 +5,11 @@ const { inheritedAuthJoi, mongoJoi, probeServerJoi, - retryParamsJoi, + retryParamsJoi } = require('../../lib/config/configItems.joi'); +const { supportedLifecycleRules } = require('../../lib/constants'); + const joiSchema = joi.object({ zookeeperPath: joi.string().required(), bucketTasksTopic: joi.string().required(), @@ -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) { diff --git a/extensions/lifecycle/bucketProcessor/LifecycleBucketProcessor.js b/extensions/lifecycle/bucketProcessor/LifecycleBucketProcessor.js index b008dacee..7b059f127 100644 --- a/extensions/lifecycle/bucketProcessor/LifecycleBucketProcessor.js +++ b/extensions/lifecycle/bucketProcessor/LifecycleBucketProcessor.js @@ -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 { @@ -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; @@ -186,6 +186,7 @@ class LifecycleBucketProcessor { lcOptions: this._lcOptions, circuitBreakers: this._circuitBreakers, log: this._log, + supportedRules: this._lcConfig.supportedLifecycleRules, }; } diff --git a/extensions/lifecycle/tasks/LifecycleTask.js b/extensions/lifecycle/tasks/LifecycleTask.js index 2c6142e7a..620ae4b8a 100644 --- a/extensions/lifecycle/tasks/LifecycleTask.js +++ b/extensions/lifecycle/tasks/LifecycleTask.js @@ -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, @@ -96,10 +95,10 @@ class LifecycleTask extends BackbeatTask { }); this._lifecycleUtils = new LifecycleUtils( - supportedLifecycleRules, + this.supportedRules, this._lifecycleDateTime ); - this._supportedRules = supportedLifecycleRules; + this._supportedRules = this.supportedRules; this._totalRetries = 0; } diff --git a/extensions/lifecycle/util/rules.js b/extensions/lifecycle/util/rules.js index 35600c030..d58f1d4aa 100644 --- a/extensions/lifecycle/util/rules.js +++ b/extensions/lifecycle/util/rules.js @@ -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 @@ -197,11 +196,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'; } @@ -222,6 +222,6 @@ function isExpirationRule(ruleName) { module.exports = { rulesToParams, - getFormattedSupportedLifecycleRules, + formatSupportedLifecycleRules, isExpirationRule, }; diff --git a/lib/config/configItems.joi.js b/lib/config/configItems.joi.js index 757cbed21..27fb0a4e1 100644 --- a/lib/config/configItems.joi.js +++ b/lib/config/configItems.joi.js @@ -158,6 +158,7 @@ const qpKafkaJoi = kafkaJoi.append({ replication: extensionKafkaJoi, }); + module.exports = { hostPortJoi, transportJoi, @@ -172,5 +173,5 @@ module.exports = { probeServerPerSite, stsConfigJoi, mongoJoi, - qpKafkaJoi, + qpKafkaJoi }; diff --git a/lib/constants.js b/lib/constants.js index bcd3334b8..b91fbb961 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -55,7 +55,14 @@ const constants = { }, ], }, - } + }, + supportedLifecycleRules: [ + 'expiration', + 'noncurrentVersionExpiration', + 'abortIncompleteMultipartUpload', + 'transitions', + 'noncurrentVersionTransition' + ] }; module.exports = constants; diff --git a/tests/functional/lifecycle/configObjects.js b/tests/functional/lifecycle/configObjects.js index f1e9fe71d..879788ea7 100644 --- a/tests/functional/lifecycle/configObjects.js +++ b/tests/functional/lifecycle/configObjects.js @@ -42,6 +42,13 @@ const lcConfig = { enabled: true, }, }, + supportedLifecycleRules: [ + 'expiration', + 'noncurrentVersionExpiration', + 'abortIncompleteMultipartUpload', + 'transitions', + 'noncurrentVersionTransition' + ] }; const repConfig = {