Skip to content

Commit 449420b

Browse files
committed
replace constant with caller-context container name
1 parent 3a15769 commit 449420b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ use crate::{
7575
},
7676
};
7777

78-
stackable_operator::constant!(VECTOR_CONTAINER_NAME: ContainerName = "vector");
7978
// The Vector container reads its `vector.yaml` from the `config` volume (the rolegroup
8079
// ConfigMap) and tails product logs from the `log` volume.
8180
stackable_operator::constant!(VECTOR_CONFIG_VOLUME_NAME: VolumeName = "config");
@@ -386,6 +385,7 @@ pub fn build_broker_rolegroup_statefulset(
386385

387386
add_vector_container(
388387
&mut pod_builder,
388+
&container_name(BrokerContainer::Vector),
389389
&validated_rg.config.logging,
390390
resolved_product_image,
391391
&resource_names,
@@ -615,6 +615,7 @@ pub fn build_controller_rolegroup_statefulset(
615615

616616
add_vector_container(
617617
&mut pod_builder,
618+
&container_name(ControllerContainer::Vector),
618619
&validated_rg.config.logging,
619620
resolved_product_image,
620621
&resource_names,
@@ -793,16 +794,24 @@ fn add_common_pod_config(
793794
/// [`ValidatedLogging`]. The container mounts the
794795
/// static `vector.yaml` from the `config` volume and is driven by the env vars the
795796
/// [`vector_container`] sets.
797+
/// The [`ContainerName`] for a role container, derived from its `Display` name so the
798+
/// Vector sidecar's container name always matches that container's logging-config key.
799+
fn container_name(container: impl std::fmt::Display) -> ContainerName {
800+
ContainerName::from_str(&container.to_string())
801+
.expect("a container enum variant is always a valid ContainerName")
802+
}
803+
796804
fn add_vector_container(
797805
pod_builder: &mut PodBuilder,
806+
vector_container_name: &ContainerName,
798807
logging: &ValidatedLogging,
799808
resolved_product_image: &ResolvedProductImage,
800809
resource_names: &ResourceNames,
801810
) {
802811
// Add vector container after kafka container to keep the defaulting into kafka container
803812
if let Some(vector_container_log_config) = &logging.vector_container {
804813
pod_builder.add_container(vector_container(
805-
&VECTOR_CONTAINER_NAME,
814+
vector_container_name,
806815
resolved_product_image,
807816
vector_container_log_config,
808817
resource_names,

0 commit comments

Comments
 (0)