Skip to content

Commit c521305

Browse files
committed
fix: restore TOPOLOGY_LABELS envvar behavior
1 parent 12bab82 commit c521305

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

rust/operator-binary/src/container.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ impl ContainerConfig {
489489
.args(self.args(hdfs, cluster_info, role, merged_config, &[])?)
490490
.add_env_vars(self.env(
491491
hdfs,
492+
role,
492493
&rolegroup_ref.role_group,
493494
zookeeper_config_map_name,
494495
env_overrides,
@@ -547,6 +548,7 @@ impl ContainerConfig {
547548
.args(self.args(hdfs, cluster_info, role, merged_config, namenode_podrefs)?)
548549
.add_env_vars(self.env(
549550
hdfs,
551+
role,
550552
role_group,
551553
zookeeper_config_map_name,
552554
env_overrides,
@@ -870,6 +872,7 @@ impl ContainerConfig {
870872
fn env(
871873
&self,
872874
hdfs: &v1alpha1::HdfsCluster,
875+
role: &HdfsNodeRole,
873876
role_group: &str,
874877
zookeeper_config_map_name: &str,
875878
env_overrides: Option<&EnvVarSet>,
@@ -907,22 +910,25 @@ impl ContainerConfig {
907910
..EnvVar::default()
908911
},
909912
);
913+
}
910914

911-
// If rack awareness is configured, expose the topology labels to the
912-
// topology-provider via an env var. This is only needed on namenodes.
913-
// Set as a default here (before the overrides below) so users can still
914-
// override it via `envOverrides`.
915-
if *role == HdfsNodeRole::Name {
916-
if let Some(rack_awareness) = hdfs.rackawareness_config() {
917-
env.insert(
918-
"TOPOLOGY_LABELS".to_string(),
919-
EnvVar {
920-
name: "TOPOLOGY_LABELS".to_string(),
921-
value: Some(rack_awareness),
922-
..EnvVar::default()
923-
},
924-
);
925-
}
915+
// If rack awareness is configured, expose the topology labels to the
916+
// topology-provider via an env var. This is set on every container of the
917+
// namenode pods (the main container as well as init/sidecar containers like
918+
// format-namenodes), since the format-namenodes init container also
919+
// instantiates the StackableTopologyProvider (which reads TOPOLOGY_LABELS).
920+
// Set as a default here (before the overrides below) so users can still
921+
// override it via `envOverrides`.
922+
if *role == HdfsNodeRole::Name {
923+
if let Some(rack_awareness) = hdfs.rackawareness_config() {
924+
env.insert(
925+
"TOPOLOGY_LABELS".to_string(),
926+
EnvVar {
927+
name: "TOPOLOGY_LABELS".to_string(),
928+
value: Some(rack_awareness),
929+
..EnvVar::default()
930+
},
931+
);
926932
}
927933
}
928934

0 commit comments

Comments
 (0)