Skip to content

feat(logstorage): validate replicas < node count to prevent ILM stall#4529

Merged
rene-dekker merged 4 commits intotigera:masterfrom
tianfeng92:fix/logstorage-validate-replicas-node-count-master
Mar 16, 2026
Merged

feat(logstorage): validate replicas < node count to prevent ILM stall#4529
rene-dekker merged 4 commits intotigera:masterfrom
tianfeng92:fix/logstorage-validate-replicas-node-count-master

Conversation

@tianfeng92
Copy link
Contributor

@tianfeng92 tianfeng92 commented Mar 11, 2026

Description

On single-node ES clusters with replicas: 1, replica shards can never be allocated. This causes the ILM warm phase migrate action to wait indefinitely for shard copies to become active, blocking progression to the delete phase and causing indices to accumulate beyond retention.

This PR adds two levels of validation in the LogStorage initializer:

  1. Error (nodeCount <= replicas): Rejects configurations where replica shards cannot be allocated at all, with a clear error message guiding users to set replicas to 0 for single-node deployments.
  2. Warning (nodeCount == replicas + 1): Logs a warning when the node count only exceeds replicas by 1, since the Elasticsearch PodDisruptionBudget will prevent voluntary pod evictions (e.g., node repaving). This is not treated as an error because it is a valid and common configuration (e.g., Calico Cloud 2-node clusters with 1 replica).

For CE master
Jira ticket: CI-1940

Release Note

Add validation for logstorage node count and replicas setting.

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@marvin-tigera marvin-tigera added this to the v1.42.0 milestone Mar 11, 2026
@tianfeng92 tianfeng92 marked this pull request as ready for review March 11, 2026 21:50
@tianfeng92 tianfeng92 requested a review from a team as a code owner March 11, 2026 21:50
@tianfeng92 tianfeng92 changed the title fix(logstorage): validate replicas < node count to prevent ILM stall feat(logstorage): validate replicas < node count to prevent ILM stall Mar 11, 2026
@tianfeng92 tianfeng92 force-pushed the fix/logstorage-validate-replicas-node-count-master branch 2 times, most recently from 0e6fd84 to cc42c9a Compare March 13, 2026 17:34
@tianfeng92 tianfeng92 requested review from rene-dekker and tmjd March 13, 2026 17:35
On single-node ES clusters with replicas: 1, replica shards can never
be allocated. This causes the ILM warm phase migrate action to wait
indefinitely for shard copies to become active, blocking progression
to the delete phase and causing indices to accumulate beyond retention.

Add validation in the LogStorage initializer that rejects configurations
where indices.replicas >= nodes.count, with a clear error message
guiding users to set replicas to 0 for single-node deployments.
@tianfeng92 tianfeng92 force-pushed the fix/logstorage-validate-replicas-node-count-master branch from cc42c9a to b0ce9ae Compare March 16, 2026 17:42
Fixes ST1008 staticcheck violation by swapping return order from
(error, string) to (string, error) in validateLogStorage and
validateReplicasForNodeCount.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rene-dekker rene-dekker merged commit 019cea5 into tigera:master Mar 16, 2026
5 checks passed
tianfeng92 added a commit to tianfeng92/operator that referenced this pull request Mar 19, 2026
Remove the warning log when LogStorage node count only exceeds replicas
by 1. The error validation (replicas >= nodeCount) is preserved.

This reverts the warning portion of PR tigera#4529.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tianfeng92 added a commit to tianfeng92/operator that referenced this pull request Mar 19, 2026
Remove the warning log when LogStorage node count only exceeds replicas
by 1. The error validation (replicas >= nodeCount) is preserved.

This reverts the warning portion of PR tigera#4529.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rene-dekker pushed a commit that referenced this pull request Mar 19, 2026
Remove the warning log when LogStorage node count only exceeds replicas
by 1. The error validation (replicas >= nodeCount) is preserved.

This reverts the warning portion of PR #4529.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
tianfeng92 added a commit to tianfeng92/operator that referenced this pull request Mar 19, 2026
Remove the warning log when LogStorage node count only exceeds replicas
by 1. The error validation (replicas >= nodeCount) is preserved.

This reverts the warning portion of PR tigera#4529.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tianfeng92 added a commit to tianfeng92/operator that referenced this pull request Mar 19, 2026
Remove the warning log when LogStorage node count only exceeds replicas
by 1. The error validation (replicas >= nodeCount) is preserved.

This reverts the warning portion of PR tigera#4529.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rene-dekker pushed a commit that referenced this pull request Mar 19, 2026
Remove the warning log when LogStorage node count only exceeds replicas
by 1. The error validation (replicas >= nodeCount) is preserved.

This reverts the warning portion of PR #4529.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
rene-dekker pushed a commit that referenced this pull request Mar 19, 2026
…4579)

* revert: remove logstorage validation warning message

Remove the warning log when LogStorage node count only exceeds replicas
by 1. The error validation (replicas >= nodeCount) is preserved.

This reverts the warning portion of PR #4529.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* empty

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants