Skip to content

Commit d90a2e2

Browse files
Merge pull request #9065 from liranmauda/liran-backport-into-5.19
[Backport into 5.19] NC | LIFECYLE | GPFS | add external binary directory and --allow-scan…
2 parents 7a549ee + a199d25 commit d90a2e2

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,9 @@ config.NC_LIFECYCLE_LIST_BATCH_SIZE = 1000;
10641064
config.NC_LIFECYCLE_BUCKET_BATCH_SIZE = 10000;
10651065

10661066
config.NC_LIFECYCLE_GPFS_ILM_ENABLED = true;
1067+
config.NC_LIFECYCLE_GPFS_ALLOW_SCAN_ON_REMOTE = true;
1068+
config.NC_GPFS_BIN_DIR = '/usr/lpp/mmfs/bin/';
1069+
10671070
////////// GPFS //////////
10681071
config.GPFS_DOWN_DELAY = 1000;
10691072

src/manage_nsfs/nc_lifecycle.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const { NewlineReader } = require('../util/file_reader');
1616
const lifecycle_utils = require('../util/lifecycle_utils');
1717
const native_fs_utils = require('../util/native_fs_utils');
1818
const SensitiveString = require('../util/sensitive_string');
19+
const { GPFS_EXTERNAL_BINS } = require('../nc/nc_constants');
1920
const { NoobaaEvent } = require('./manage_nsfs_events_utils');
2021
const notifications_util = require('../util/notifications_util');
2122
const ManageCLIError = require('./manage_nsfs_cli_errors').ManageCLIError;
@@ -55,6 +56,16 @@ const TIMED_OPS = Object.freeze({
5556
* }} RuleState
5657
*/
5758

59+
/**
60+
* get_bin_path returns the full path to the binary file.
61+
* @param {String} bin_dir
62+
* @param {String} bin_name
63+
* @returns {String}
64+
*/
65+
function get_bin_path(bin_dir, bin_name) {
66+
return path.join(bin_dir, bin_name);
67+
}
68+
5869
class NCLifecycle {
5970
constructor(config_fs, options = {}) {
6071
this.lifecycle_config_dir_path = path.join(config_fs.config_root, config.NC_LIFECYCLE_CONFIG_DIR_NAME);
@@ -1134,7 +1145,9 @@ class NCLifecycle {
11341145
*/
11351146
async get_mount_points_map() {
11361147
try {
1137-
const fs_list = await os_utils.exec(`mmlsfs all -T -Y`, { return_stdout: true });
1148+
const binary_file_path = get_bin_path(config.NC_GPFS_BIN_DIR, GPFS_EXTERNAL_BINS.MMLSFS);
1149+
const command = `${binary_file_path} all -T -Y`;
1150+
const fs_list = await os_utils.exec(command, { return_stdout: true });
11381151
dbg.log2('get_mount_points fs_list res ', fs_list);
11391152
const lines = fs_list.trim().split('\n');
11401153
const res = {};
@@ -1376,15 +1389,16 @@ class NCLifecycle {
13761389
/**
13771390
* create_candidates_file_by_gpfs_ilm_policy gets the candidates by applying the ILM policy using mmapplypolicy
13781391
* the return value is a path to the output file that contains the candidates
1379-
* TODO - check if the output file is created - this is probablt not the correct path
13801392
* @param {String} mount_point_path
13811393
* @param {String} ilm_policy_tmp_path
13821394
* @returns {Promise<Void>}
13831395
*/
13841396
async create_candidates_file_by_gpfs_ilm_policy(mount_point_path, ilm_policy_tmp_path) {
13851397
try {
1386-
// TODO - understand which is better defer or prepare
1387-
const mmapply_policy_res = await os_utils.exec(`mmapplypolicy ${mount_point_path} -P ${ilm_policy_tmp_path} -f ${ILM_CANDIDATES_TMP_DIR} -I defer`, { return_stdout: true });
1398+
const binary_file_path = get_bin_path(config.NC_GPFS_BIN_DIR, GPFS_EXTERNAL_BINS.MMAPPLYPOLICY);
1399+
const allow_scan_on_remote = config.NC_LIFECYCLE_GPFS_ALLOW_SCAN_ON_REMOTE ? '--allow-scan-on-remote' : '';
1400+
const command = `${binary_file_path} ${mount_point_path} -P ${ilm_policy_tmp_path} ${allow_scan_on_remote} -f ${ILM_CANDIDATES_TMP_DIR} -I defer `;
1401+
const mmapply_policy_res = await os_utils.exec(command, { return_stdout: true });
13881402
dbg.log2('create_candidates_file_by_gpfs_ilm_policy mmapplypolicy res ', mmapply_policy_res);
13891403
} catch (err) {
13901404
throw new Error(`create_candidates_file_by_gpfs_ilm_policy failed with error ${err}`);

src/nc/nc_constants.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* Copyright (C) 2024 NooBaa */
2+
'use strict';
3+
4+
const GPFS_EXTERNAL_BINS = Object.freeze({
5+
MMAPPLYPOLICY: 'mmapplypolicy',
6+
MMLSFS: 'mmlsfs'
7+
});
8+
9+
// EXPORTS
10+
exports.GPFS_EXTERNAL_BINS = GPFS_EXTERNAL_BINS;

0 commit comments

Comments
 (0)