Skip to content

Allow Days=0 in lifecycle rules (relax day-based actions to nonnegative)#2648

Open
delthas wants to merge 3 commits into
development/8.4from
improvement/ARSN-597/allow-days-0-lifecycle-rules
Open

Allow Days=0 in lifecycle rules (relax day-based actions to nonnegative)#2648
delthas wants to merge 3 commits into
development/8.4from
improvement/ARSN-597/allow-days-0-lifecycle-rules

Conversation

@delthas

@delthas delthas commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What

Allow Days = 0 in S3 lifecycle rules. Previously the day-based actions required a value >= 1; this accepts 0 (nonnegative) for:

  • ExpirationDays
  • NoncurrentVersionExpirationNoncurrentDays
  • AbortIncompleteMultipartUploadDaysAfterInitiation

All three now go through the existing _checkDays() helper (already used by Transition / NoncurrentVersionTransition), which accepts 0..MAX_DAYS and returns must be nonnegative / must not exceed errors. As a side effect this adds the MAX_DAYS (2³¹−1) upper bound that these three actions previously lacked, consistent with the transition actions.

Why

Days = 0 is meant as an explicit "empty this bucket" intent. Backbeat (BB-779) keys on it to skip building the v2 lifecycle index, which is expensive (~5–10× its size in transient disk during the merge-sort) and pointless when a bucket is being drained.

Days = 1 can't serve this purpose because legitimate short-retention buckets (logs, etc.) use it. Since Days = 0 was rejected everywhere until now, it is an unambiguous marker that cannot collide with any previously-valid configuration.

This intentionally diverges from AWS S3 (which requires Days >= 1) — that divergence is exactly what makes 0 a safe internal signal.

Falsy-zero fixes

Accepting 0 exposed several spots that treated the day value as falsy and would have silently dropped a Days = 0 rule. Fixed so the rule is preserved end to end:

  • _parseAction copied action times with if (action[t]) → now !== undefined
  • getConfigXml serialized Expiration Days with days ? … → now days !== undefined (otherwise GetBucketLifecycle returned an Expiration with no action time)
  • _validateRules skipped the type assertion when days === 0
  • LifecycleUtils.getApplicableRules guards/comparisons dropped 0 before it could be selected as the earliest applicable action — this is the path that feeds expiration decisions

Scope

  • NewerNoncurrentVersions keeps its >= 1 rule (it is a count, not a number of days).
  • Consumers are handled separately: the cloudserver dependency bump + functional tests, and the backbeat skip-index heuristic (BB-779).

Issue: ARSN-597

@bert-e

bert-e commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Hello delthas,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@bert-e

bert-e commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.46875% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.04%. Comparing base (5981b88) to head (7d3bb94).
⚠️ Report is 8 commits behind head on development/8.4.

Files with missing lines Patch % Lines
lib/models/LifecycleConfiguration.ts 76.63% 25 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           development/8.4    #2648      +/-   ##
===================================================
+ Coverage            74.00%   74.04%   +0.03%     
===================================================
  Files                  229      229              
  Lines                18503    18504       +1     
  Branches              3820     3837      +17     
===================================================
+ Hits                 13694    13702       +8     
+ Misses                4804     4797       -7     
  Partials                 5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claude

claude Bot commented Jun 18, 2026

Copy link
Copy Markdown

LGTM

The falsy-zero fixes are thorough and correct throughout the pipeline: parsing (_parseAction, _parseExpiration, _parseNoncurrentVersionExpiration, _parseAbortIncompleteMultipartUpload), serialization (getConfigXml), validation (validateConfig), and rule selection (getApplicableRules). Consolidating the three day-based actions to use the existing _checkDays() helper is a nice simplification that also adds the MAX_DAYS upper bound consistently. Test coverage for the new Days=0 acceptance, the updated error messages, and the exceed-max-days cases is comprehensive.

Review by Claude Code

@scality scality deleted a comment from claude Bot Jun 18, 2026
Comment thread lib/models/LifecycleConfiguration.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be confirmed by product team : can this be allowed everywhere, or do we need to make this opt-in so it can be selectively allowed?

Comment thread lib/s3middleware/lifecycleHelpers/LifecycleUtils.ts Outdated
Comment thread lib/models/LifecycleConfiguration.ts
Comment thread lib/models/LifecycleConfiguration.ts Outdated
Comment thread lib/models/LifecycleConfiguration.ts
const error = this._checkDays({
days: daysInt,
field: 'NoncurrentDays',
ancestor: 'NoncurrentVersionExpiration',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember exactly the design but should we allow everything to be 0 days ? My point is : if we want to empty a bucket, maybe we should only allow to expire "current version" and first clean everything else after one day ? It's a matter of safety but allowing 0 everywhere give more flexibility to our customer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say more flexibility, and safety can be done with a UI warning etc. Currently users can mess up their install badly if they do weird stuff with the API anyway.

@scality scality deleted a comment from bert-e Jun 19, 2026
@scality scality deleted a comment from bert-e Jun 21, 2026
@delthas delthas force-pushed the improvement/ARSN-597/allow-days-0-lifecycle-rules branch from 72e5d59 to 4f0ac7f Compare June 22, 2026 10:17
@scality scality deleted a comment from bert-e Jun 22, 2026
@bert-e

bert-e commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Request integration branches

Waiting for integration branch creation to be requested by the user.

To request integration branches, please comment on this pull request with the following command:

/create_integration_branches

Alternatively, the /approve and /create_pull_requests commands will automatically
create the integration branches.

delthas added 3 commits June 22, 2026 21:50
Pure formatting pass (no logic change) on the files touched by the Days=0
change, so the prettier CI check (which runs on whole files modified by the
PR) passes. Isolating the reformat here keeps the functional commit's diff
reviewable.

Issue: ARSN-597
S3 lifecycle day-based actions previously required a value >= 1. Accept 0
(nonnegative) for Expiration Days, NoncurrentVersionExpiration NoncurrentDays,
and AbortIncompleteMultipartUpload DaysAfterInitiation by routing them through
the existing _checkDays() helper. This also adds the MAX_DAYS upper bound these
three actions lacked, consistent with Transitions.

Days=0 is an explicit "empty this bucket" intent: because it was rejected
before, it is an unambiguous signal (unlike Days=1, which legitimate
short-retention buckets use) that backbeat can key on to skip building costly
lifecycle indexes (BB-779).

Also fix falsy-zero handling so a Days=0 rule is preserved end to end:
- _parseAction copied action times with `if (action[t])`, dropping days=0
- getConfigXml serialized Expiration Days with `days ? ...`, dropping 0
- _validateRules skipped the type assertion for days=0
- LifecycleUtils.getApplicableRules guards/comparisons dropped 0 before it
  could be selected as the earliest applicable action

Issue: ARSN-597
A 0-day action time (now accepted) triggers immediate processing, e.g.
emptying a bucket. Emit an audit log when one is configured so an
accidental or malformed rule is traceable.

Thread a werelogs logger into the LifecycleConfiguration constructor
(mirroring ReplicationConfiguration) and log from the shared _checkDays
helper, which covers Expiration, NoncurrentVersionExpiration,
AbortIncompleteMultipartUpload and Transition day actions.

Callers must now pass a logger; the CloudServer caller is updated
separately.

Issue: ARSN-597
@delthas delthas force-pushed the improvement/ARSN-597/allow-days-0-lifecycle-rules branch from 4f0ac7f to 7d3bb94 Compare June 22, 2026 19:51
@scality scality deleted a comment from bert-e Jun 22, 2026
@scality scality deleted a comment from bert-e Jun 27, 2026
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.

4 participants