Skip to content

Mirror upstream elastic/elasticsearch#134941 for AI review (snapshot of HEAD tree)#120

Closed
phananh1010 wants to merge 1 commit intoupstream-mainfrom
eval/pr-134941-diff
Closed

Mirror upstream elastic/elasticsearch#134941 for AI review (snapshot of HEAD tree)#120
phananh1010 wants to merge 1 commit intoupstream-mainfrom
eval/pr-134941-diff

Conversation

@phananh1010
Copy link
Owner

@phananh1010 phananh1010 commented Oct 7, 2025

Single commit with tree=cdd8ceeee7541f2657e7528f58c5dffd4e5adc2e^{tree}, parent=6a1d6bf45243b971e81384c6edb3d9a44a0580b8. Exact snapshot of upstream PR head. No conflict resolution attempted.

Summary by CodeRabbit

  • New Features

    • Improved automatic rollover timing for data streams with very small retentions: when retention is ≤1 day, auto max_age now defaults to 1 hour for both main and failure stores, ensuring timely rollovers.
  • Documentation

    • Added changelog entry describing the enhanced rollover behavior for tiny retentions.
  • Tests

    • Added REST and unit tests validating 1-hour auto max_age for tiny retentions and updated expectations for boundary cases (≤1 day).
BASE=6a1d6bf45243b971e81384c6edb3d9a44a0580b8
HEAD=cdd8ceeee7541f2657e7528f58c5dffd4e5adc2e
Branch=main
@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Walkthrough

Introduces an auto max_age rollover rule for tiny retentions (<=1d) set to 1h in RolloverConfiguration, updates unit tests accordingly, adds a YAML REST test validating lifecycle and failure store behavior with tiny retentions, and documents the change in the changelog.

Changes

Cohort / File(s) Summary
Rollover auto max_age logic
server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfiguration.java
Adds a new conditional branch: when retention <= 1d, auto max_age evaluates to 1h; retains existing thresholds for >1d.
Rollover logic tests
server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfigurationTests.java
Updates expectations: 1d now maps to 1h; adds assertions for 23h/12h/1h/0h mapping to 1h.
Data stream lifecycle tests
modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java
Adds testWithTinyRetentions: builds data streams with 1d and 12h retentions; asserts two rollovers with max_age=1h.
YAML REST test
modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/270_small_retention.yml
New REST test verifying template settings and that lifecycle and failure store rollover max_age auto-evaluates to 1h for tiny retentions.
Changelog
docs/changelog/134941.yaml
Adds entry: DLM improvement for better auto max_age rollover with tiny retentions; references issue 130960.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant DSL as DataStreamLifecycleService
  participant RC as RolloverConfiguration
  participant ES as Elasticsearch Cluster

  User->>DSL: Trigger lifecycle run
  DSL->>RC: evaluateMaxAgeCondition(retention, max_age=auto)
  alt retention <= 1d
    Note right of RC: New path: auto max_age = 1h
    RC-->>DSL: 1h
  else retention <= 14d / <=90d / >90d
    RC-->>DSL: 1d / 7d / 30d
  end
  DSL->>ES: RolloverRequest(main DS, max_age)
  DSL->>ES: RolloverRequest(failure store, max_age)
  ES-->>DSL: Acknowledge rollovers
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I nudge the clock from day to hour,
A tiny hop with timely power. ⏳🐇
Two rollovers spin, both neat and clean,
For small retentions, swift and keen.
Carrots count the ticks—one hour, done!
On streams we bound; the work is fun.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly expresses that this pull request mirrors upstream elastic#134941 for AI review, matching the main objective of the changeset. It is concise and specific enough for teammates to understand the purpose at a glance.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch eval/pr-134941-diff

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a1d6bf and ee0ddba.

📒 Files selected for processing (5)
  • docs/changelog/134941.yaml (1 hunks)
  • modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java (2 hunks)
  • modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/270_small_retention.yml (1 hunks)
  • server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfiguration.java (1 hunks)
  • server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfigurationTests.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java (2)
server/src/main/java/org/elasticsearch/cluster/metadata/ProjectMetadata.java (1)
  • ProjectMetadata (86-2332)
libs/core/src/main/java/org/elasticsearch/core/TimeValue.java (1)
  • TimeValue (16-458)
server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfigurationTests.java (2)
server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfiguration.java (1)
  • RolloverConfiguration (33-407)
libs/core/src/main/java/org/elasticsearch/core/TimeValue.java (1)
  • TimeValue (16-458)
server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfiguration.java (1)
libs/core/src/main/java/org/elasticsearch/core/TimeValue.java (1)
  • TimeValue (16-458)
🪛 YAMLlint (1.37.1)
modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/270_small_retention.yml

[error] 15-15: too many spaces inside brackets

(brackets)


[error] 15-15: too many spaces inside brackets

(brackets)


[error] 20-20: too many spaces inside brackets

(brackets)


[error] 20-20: too many spaces inside brackets

(brackets)


[error] 46-46: too many spaces inside braces

(braces)


[error] 46-46: too many spaces inside braces

(braces)


[error] 47-47: too many spaces inside braces

(braces)


[error] 47-47: too many spaces inside braces

(braces)


[error] 48-48: too many spaces inside braces

(braces)


[error] 48-48: too many spaces inside braces

(braces)


[error] 49-49: too many spaces inside braces

(braces)


[error] 49-49: too many spaces inside braces

(braces)


[error] 50-50: too many spaces inside braces

(braces)


[error] 50-50: too many spaces inside braces

(braces)


[error] 51-51: too many spaces inside braces

(braces)


[error] 51-51: too many spaces inside braces

(braces)


[error] 52-52: too many spaces inside braces

(braces)


[error] 52-52: too many spaces inside braces

(braces)


[error] 53-53: too many spaces inside braces

(braces)


[error] 53-53: too many spaces inside braces

(braces)

🔇 Additional comments (5)
server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfigurationTests.java (1)

271-275: LGTM! Comprehensive boundary testing for tiny retentions.

The test updates correctly validate the new heuristic where retention ≤ 1 day yields a 1-hour max_age. The addition of boundary cases (23h, 12h, 1h, 0h) provides thorough coverage of edge conditions.

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverConfiguration.java (1)

176-187: LGTM! Clean implementation of the tiny retention heuristic.

The addition of the early branch for retention ≤ 1 day returning 1 hour is well-implemented. The javadoc accurately describes the updated behavior, and the logic correctly handles the new threshold before checking larger retention periods.

modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java (1)

1170-1215: LGTM! Thorough validation of tiny retention rollover behavior.

The test correctly validates that:

  1. Both main and failure store data streams trigger rollover requests
  2. The max_age is set to 1 hour for both streams despite different retention values (1 day for main, 12 hours for failure)
  3. The rollover targets are correctly identified

This provides good integration test coverage for the new tiny retention heuristic.

docs/changelog/134941.yaml (1)

1-6: LGTM! Clear and concise changelog entry.

The changelog properly documents the enhancement for better max_age rollover handling with tiny retentions, correctly categorized as a Data streams enhancement with appropriate issue reference.

modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/270_small_retention.yml (1)

1-53: LGTM – YAML spacing is consistent with existing test files; no formatting changes required.


Comment @coderabbitai help to get the list of available commands and usage tips.

@phananh1010 phananh1010 closed this Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant