Skip to content

Support configurable replica count in valkey-cluster-init job#17

Open
the-mentor wants to merge 1 commit into
kagent-dev:mainfrom
the-mentor:valkey-init-configurable-replicas
Open

Support configurable replica count in valkey-cluster-init job#17
the-mentor wants to merge 1 commit into
kagent-dev:mainfrom
the-mentor:valkey-init-configurable-replicas

Conversation

@the-mentor

Copy link
Copy Markdown

Summary

The valkey-cluster-init Job hardcoded for i in 0 1 2 3 4 5 loops, assuming exactly 6 Valkey pods. Any other valkey.replicas value would break:

  • DNS wait loop would wait for pods 0-5 regardless of actual count (hanging forever if fewer, missing pods if more).
  • IP gathering loop would build the wrong --cluster create node list, so cluster creation would fail or omit nodes.

Meanwhile the StatefulSet already scales via .Values.valkey.replicas (default 6), so the init job was the only thing pinned to 6.

Changes

  • Inject the replica count from Helm (REPLICAS={{ .Values.valkey.replicas }}).
  • Replace both hardcoded for loops with POSIX-safe while loops that iterate 0 .. REPLICAS-1.

Testing

  • helm template charts/substrate → renders REPLICAS=6 (default, unchanged behavior).
  • helm template charts/substrate --set valkey.replicas=3 → renders REPLICAS=3 with the loops iterating over it.

🤖 Generated with Claude Code

The init job hardcoded `for i in 0 1 2 3 4 5` loops, assuming exactly 6
Valkey pods. This broke DNS resolution and cluster creation for any other
`valkey.replicas` value. Inject the replica count from Helm and iterate
over it with a POSIX-safe while loop so the job works for any count.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant