fix(es): Reject negative index retention - #9123
Open
viiccwen wants to merge 1 commit into
Open
Conversation
Signed-off-by: viiccwen <vicwen@apache.org>
Contributor
There was a problem hiding this comment.
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_DAYSvalues 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. |
|
Hi @viiccwen, thanks for your contribution! To ensure quality reviews, we limit how many concurrent PRs new contributors can open:
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
Description of the changes
NUM_OF_DAYSvalues before initializing configuration or connecting to Elasticsearch.How was this change tested?
make fmtmake lintmake testChecklist
make lint testAI Usage in this PR (choose one)
See AI Usage Policy.