Skip to content

Conversation

@tennisleng
Copy link
Contributor

Summary

Fixes #1055
Fixes #932

This PR fixes two issues with lifecycle processing that were causing objects to not be deleted according to lifecycle rules.

Root Causes

  1. Missing is_latest field in ObjectInfo: The scanner convert_record_to_object_info was not setting is_latest field.

  2. Panic on missing mod_time: The lifecycle evaluation code used obj.mod_time.expect() which would panic.

Changes

crates/ahm/src/scanner/data_scanner.rs

  • Fixed convert_record_to_object_info to set is_latest: usage.has_live_object

crates/ecstore/src/bucket/lifecycle/lifecycle.rs

  • Fixed eval_inner to gracefully handle None mod_time instead of panicking
  • Updated all obj.mod_time.unwrap() usages to use an extracted mod_time variable

Testing

  • Build verified with cargo check -p rustfs-ecstore -p rustfs-ahm

Related

tennisleng and others added 4 commits December 9, 2025 17:40
Fixes rustfs#1055
Fixes rustfs#932

This commit fixes two issues with lifecycle processing:

1. Scanner's convert_record_to_object_info now sets is_latest field to true
   for live objects. This is required for lifecycle expiration evaluation,
   which checks (obj.is_latest || obj.version_id.is_empty()) before
   evaluating expiration rules.

2. Lifecycle eval_inner now gracefully handles missing mod_time instead
   of panicking with expect(). Objects with missing modification time
   are skipped with an informative log message.

Together, these changes ensure that:
- Objects are properly evaluated for lifecycle expiration rules
- Scanner processing doesn't panic on objects with incomplete metadata
@loverustfs
Copy link
Contributor

Hey @tennisleng ,

Thank you for your contribution!
We discovered that CI failed before the merge.

Run cargo fmt --all --check
Diff in /home/runner/work/rustfs/rustfs/crates/ecstore/src/bucket/lifecycle/lifecycle.rs:283:
             "eval_inner: object={}, mod_time={:?}, now={:?}, is_latest={}, delete_marker={}",
             obj.name, obj.mod_time, now, obj.is_latest, obj.delete_marker
         );
-        
+
         // Gracefully handle missing mod_time instead of panicking
         let mod_time = match obj.mod_time {
             Some(t) => t,
Diff in /home/runner/work/rustfs/rustfs/crates/ecstore/src/bucket/lifecycle/lifecycle.rs:292:
                 return Event::default();
             }
         };
-        
+
         if mod_time.unix_timestamp() == 0 {
             info!("eval_inner: mod_time is 0, returning default event");
             return Event::default();
Error: Process completed with exit code 1.

@tennisleng
Copy link
Contributor Author

Hey @tennisleng ,

Thank you for your contribution! We discovered that CI failed before the merge.

Run cargo fmt --all --check
Diff in /home/runner/work/rustfs/rustfs/crates/ecstore/src/bucket/lifecycle/lifecycle.rs:283:
             "eval_inner: object={}, mod_time={:?}, now={:?}, is_latest={}, delete_marker={}",
             obj.name, obj.mod_time, now, obj.is_latest, obj.delete_marker
         );
-        
+
         // Gracefully handle missing mod_time instead of panicking
         let mod_time = match obj.mod_time {
             Some(t) => t,
Diff in /home/runner/work/rustfs/rustfs/crates/ecstore/src/bucket/lifecycle/lifecycle.rs:292:
                 return Event::default();
             }
         };
-        
+
         if mod_time.unix_timestamp() == 0 {
             info!("eval_inner: mod_time is 0, returning default event");
             return Event::default();
Error: Process completed with exit code 1.

done

@loverustfs loverustfs merged commit 978845b into rustfs:main Dec 10, 2025
13 of 14 checks passed
@loverustfs
Copy link
Contributor

Thanks for your contribution.
It has been merged.

@tennisleng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Life cycle does not work data_scanner need to handle object heal, replication, and lifecycle operations

2 participants