Skip to content

Commit bad1524

Browse files
committed
fix(kafka): correct the stale co-namespaced migration render error
The brokerPoolName render guard still told operators to "migrate one at a time or use separate namespaces" when a sibling cluster owned the shared "kafka" pool. That predates automatic name freeing: the migration hook now drains the first cluster off the shared pool with a Cruise Control rebalance and releases the name, and the waiting cluster's HelmRelease retries into it — every co-namespaced Kafka reaches KRaft, no manual action required. Reword the fail message and the helper comment to describe the transient wait-and-retry, and update the unit test's error pattern to match. Signed-off-by: Alexey Artamonov <[email protected]>
1 parent 0b93328 commit bad1524

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

‎packages/apps/kafka/templates/_versions.tpl‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,15 @@
8989
absence: a real fresh install, or a client-side render (helm template/unittest)
9090
that is never applied.
9191
92-
Because "kafka" is a fixed, namespace-unique name, only ONE ZooKeeper->KRaft
93-
migration can run per namespace: if a "kafka" pool owned by a different cluster
94-
already exists, a second migration fails closed (Strimzi guidance is one Kafka
95-
per namespace — strimzi/strimzi-kafka-operator discussions/11120). Fresh KRaft
96-
clusters are never affected. lookup returns nothing during `helm template`, so
97-
unit tests resolve to the fresh "b-<hash>" default.
92+
Because "kafka" is a fixed, namespace-unique name, co-namespaced ZooKeeper->KRaft
93+
migrations run one at a time: while another cluster owns the "kafka" pool, this
94+
cluster's render fails closed and its HelmRelease retries. The migration hook
95+
drains the first cluster off the shared pool with a Cruise Control rebalance and
96+
frees the name, then the waiting cluster retries into it — so every co-namespaced
97+
Kafka reaches KRaft, not just the first (strimzi/strimzi-kafka-operator
98+
discussions/11120). Fresh KRaft clusters are never affected. lookup returns
99+
nothing during `helm template`, so unit tests resolve to the fresh "b-<hash>"
100+
default.
98101
*/ -}}
99102
{{- define "kafka.brokerPoolName" -}}
100103
{{- $release := .Release.Name -}}
@@ -118,7 +121,7 @@
118121
{{- else if and $existingCR (ne $kraftAnn "enabled") -}}
119122
{{- /* Classic ZooKeeper cluster about to migrate: adopt its brokers as "kafka". */ -}}
120123
{{- if and $kp (ne $kpOwner "") (ne $kpOwner $release) -}}
121-
{{- fail (printf "cannot migrate Kafka %q: namespace %q already has a \"kafka\" broker pool owned by cluster %q. Strimzi node pool names are namespace-unique, so only one ZooKeeper->KRaft migration per namespace is possible (see strimzi/strimzi-kafka-operator discussions/11120). Migrate one at a time or use separate namespaces; fresh KRaft clusters are unaffected." $release $ns $kpOwner) -}}
124+
{{- fail (printf "Kafka %q is waiting to migrate: namespace %q still has the shared \"kafka\" broker pool owned by cluster %q, which is migrating first. Strimzi node pool names are namespace-unique, so co-namespaced ZooKeeper->KRaft migrations run one at a time (see strimzi/strimzi-kafka-operator discussions/11120): %q drains off the shared pool and frees the name, then this HelmRelease retries into it automatically — no manual action needed. Fresh KRaft clusters are unaffected." $release $ns $kpOwner $kpOwner) -}}
122125
{{- end -}}
123126
{{- $name = "kafka" -}}
124127
{{- end -}}

‎packages/apps/kafka/tests/migration-hook_test.yaml‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,12 @@ tests:
195195
pattern: 'brokerPool="kafka"'
196196
documentIndex: 3
197197

198-
# Render-time defense-in-depth for the one-migration-per-namespace rule: if a
199-
# "kafka" pool is already owned by a DIFFERENT cluster while this ZooKeeper
200-
# cluster tries to migrate, kafka.brokerPoolName fails the render outright
201-
# (the hook's runtime create-CAS is the second line of defense).
202-
- it: fails the render when a foreign cluster already owns the kafka pool
198+
# Render-time serialization of co-namespaced migrations: while a "kafka" pool is
199+
# owned by a DIFFERENT cluster that is migrating first, kafka.brokerPoolName
200+
# fails this ZooKeeper cluster's render so its HelmRelease retries until the
201+
# first cluster drains off the shared pool and frees the name (the hook's
202+
# runtime create-CAS is the second line of defense).
203+
- it: fails the render when a foreign cluster still owns the kafka pool
203204
release:
204205
name: test-kafka
205206
namespace: tenant-test
@@ -232,7 +233,7 @@ tests:
232233
strimzi.io/cluster: other-cluster
233234
asserts:
234235
- failedTemplate:
235-
errorPattern: "already has a .* broker pool owned by cluster"
236+
errorPattern: "broker pool owned by cluster .* migrating first"
236237

237238
# The controller pool the hook creates must use the short hashed name
238239
# kafka.controllerPoolName, in lockstep with every selector helper.

0 commit comments

Comments
 (0)