Skip to content

Commit 5f9af01

Browse files
committed
NC | lifecycle | add noncurrent days rule
Signed-off-by: nadav mizrahi <nadav.mizrahi16@gmail.com>
1 parent 7a18cdb commit 5f9af01

File tree

4 files changed

+187
-31
lines changed

4 files changed

+187
-31
lines changed

src/manage_nsfs/nc_lifecycle.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ class NCLifecycle {
588588

589589
/**
590590
* check if object is delete candidate based on newer noncurrent versions rule
591-
* @param {Object} object_info
591+
* @param {nb.ObjectInfo} object_info
592592
* @param {Object} newer_noncurrent_state
593593
* @param {Number} num_newer_versions
594594
* @returns
@@ -608,21 +608,22 @@ class NCLifecycle {
608608

609609
/**
610610
* check if object is delete candidate based on number of noncurrent days rule
611-
* @param {Object} object_info
611+
* @param {nb.ObjectInfo} object_info
612612
* @param {Number} num_non_current_days
613613
* @returns
614614
*/
615615
filter_noncurrent_days(object_info, num_non_current_days) {
616-
//TODO implement
617-
return true;
616+
if (object_info.is_latest) return false;
617+
const noncurrent_time = object_info.nc_noncurrent_time;
618+
return lifecycle_utils.get_file_age_days(noncurrent_time) >= num_non_current_days;
618619
}
619620

620621
/**
621622
* get_candidates_by_noncurrent_version_expiration_rule processes the noncurrent version expiration rule
622623
* TODO:
623624
* POSIX - need to support both noncurrent_days and newer_noncurrent_versions
624625
* GPFS - implement noncurrent_days using GPFS ILM policy as an optimization
625-
* @param {*} lifecycle_rule
626+
* @param {Object} lifecycle_rule
626627
* @param {Object} bucket_json
627628
* @returns {Promise<Object[]>}
628629
*/

src/sdk/namespace_fs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,8 @@ class NamespaceFS {
26342634
const storage_class = Glacier.storage_class_from_xattr(stat.xattr);
26352635
const size = Number(stat.xattr?.[XATTR_DIR_CONTENT] || stat.size);
26362636
const tag_count = stat.xattr ? this._number_of_tags_fs_xttr(stat.xattr) : 0;
2637+
const nc_noncurrent_time = (stat.xattr?.[XATTR_NON_CURRENT_TIMESTASMP] && Number(stat.xattr[XATTR_NON_CURRENT_TIMESTASMP])) ||
2638+
stat.ctime.getTime();
26372639

26382640
return {
26392641
obj_id: etag,
@@ -2652,6 +2654,7 @@ class NamespaceFS {
26522654
xattr: to_xattr(stat.xattr),
26532655
tag_count,
26542656
tagging: get_tags_from_xattr(stat.xattr),
2657+
nc_noncurrent_time,
26552658

26562659
// temp:
26572660
lock_settings: undefined,

src/sdk/nb.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ interface ObjectInfo {
442442
restore_status?: RestoreStatus;
443443
checksum?: Checksum;
444444
object_parts?: GetObjectAttributesParts;
445+
nc_noncurrent_time ?: number;
445446
}
446447

447448

0 commit comments

Comments
 (0)