rustfs icon indicating copy to clipboard operation
rustfs copied to clipboard

fix(lifecycle): Fix ObjectInfo fields and mod_time error handling

Open tennisleng opened this issue 2 weeks ago • 1 comments

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

  • Prerequisite for #1049 (cold tier configuration module)
  • See also #1087 (API error handling fix)

tennisleng avatar Dec 09 '25 22:12 tennisleng

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.

loverustfs avatar Dec 10 '25 13:12 loverustfs

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

tennisleng avatar Dec 10 '25 20:12 tennisleng

Thanks for your contribution. It has been merged.

@tennisleng

loverustfs avatar Dec 10 '25 23:12 loverustfs