Skip to content

fix(es): Reject negative index retention - #9123

Open
viiccwen wants to merge 1 commit into
jaegertracing:mainfrom
viiccwen:fix/index-cleaner-negative-retention
Open

fix(es): Reject negative index retention#9123
viiccwen wants to merge 1 commit into
jaegertracing:mainfrom
viiccwen:fix/index-cleaner-negative-retention

Conversation

@viiccwen

Copy link
Copy Markdown

Which problem is this PR solving?

Description of the changes

  • Reject negative NUM_OF_DAYS values before initializing configuration or connecting to Elasticsearch.
  • Preserve the existing behavior for zero and positive retention values.
  • Add a CLI regression test for negative retention.

How was this change tested?

  • make fmt
  • make lint
  • make test

Checklist

AI Usage in this PR (choose one)

See AI Usage Policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

Signed-off-by: viiccwen <vicwen@apache.org>
@viiccwen
viiccwen requested a review from a team as a code owner July 26, 2026 10:55
Copilot AI review requested due to automatic review settings July 26, 2026 10:55

Copilot AI left a comment

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.

Pull request overview

This PR fixes a safety bug in the Elasticsearch index cleaner CLI by rejecting negative retention values (NUM_OF_DAYS < 0) early at startup, preventing deletion cutoff dates from moving into the future and potentially selecting too-new indices for deletion.

Changes:

  • Add argument validation to reject negative NUM_OF_DAYS values before config initialization and Elasticsearch client creation.
  • Add a CLI-style regression test that executes the test binary as a subprocess and asserts the validation error is surfaced.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/es-index-cleaner/main.go Adds non-negative validation for NUM_OF_DAYS before config init / ES client creation.
cmd/es-index-cleaner/main_test.go Adds a subprocess-based regression test asserting negative retention is rejected with the expected error message.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Hi @viiccwen, thanks for your contribution! To ensure quality reviews, we limit how many concurrent PRs new contributors can open:

  • Open: 5
  • Limit: 1

This PR is currently on hold. We will automatically move this into the review queue once your existing PRs are merged or closed.

Please see our Contributing Guidelines for details on our tiered quota policy.

@github-actions github-actions Bot added the pr-quota-reached Tags PRs that exceed the PR limits for new contributors label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage pr-quota-reached Tags PRs that exceed the PR limits for new contributors storage/elasticsearch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Elasticsearch index cleaner accepts a negative retention duration

2 participants