Skip to content

Commit 5e2a59e

Browse files
committed
use cluster name instead of uid for kafka cluster-id
1 parent 3decd23 commit 5e2a59e

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

rust/operator-binary/src/crd/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ impl v1alpha1::KafkaCluster {
207207
self.spec.controllers.is_some()
208208
}
209209

210-
pub fn uid(&self) -> Option<&str> {
211-
self.metadata.uid.as_deref()
210+
// The cluster-id for Kafka
211+
pub fn cluster_id(&self) -> Option<&str> {
212+
self.metadata.name.as_deref()
212213
}
213214

214215
/// The name of the load-balanced Kubernetes Service providing the bootstrap address. Kafka clients will use this

rust/operator-binary/src/resource/statefulset.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ pub enum Error {
149149
#[snafu(display("failed to retrieve rolegroup replicas"))]
150150
RoleGroupReplicas { source: crd::role::Error },
151151

152-
#[snafu(display("cluster does not define UID"))]
153-
ClusterUidMissing,
152+
#[snafu(display(
153+
"cluster does not define 'metadata.name' which is required for the Kafka cluster id"
154+
))]
155+
ClusterIdMissing,
154156

155157
#[snafu(display("vector agent is enabled but vector aggregator ConfigMap is missing"))]
156158
VectorAggregatorConfigMapMissing,
@@ -291,7 +293,7 @@ pub fn build_broker_rolegroup_statefulset(
291293
)
292294
.context(InvalidKafkaListenersSnafu)?;
293295

294-
let cluster_id = kafka.uid().context(ClusterUidMissingSnafu)?;
296+
let cluster_id = kafka.cluster_id().context(ClusterIdMissingSnafu)?;
295297

296298
cb_kafka
297299
.image_from_product_image(resolved_product_image)
@@ -648,7 +650,7 @@ pub fn build_controller_rolegroup_statefulset(
648650
"-c".to_string(),
649651
])
650652
.args(vec![controller_kafka_container_command(
651-
kafka.uid().context(ClusterUidMissingSnafu)?,
653+
kafka.cluster_id().context(ClusterIdMissingSnafu)?,
652654
kafka
653655
.pod_descriptors(kafka_role, cluster_info)
654656
.context(BuildPodDescriptorsSnafu)?,

0 commit comments

Comments
 (0)