diff --git a/CHANGELOG.md b/CHANGELOG.md index 72ad617a..71627928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ All notable changes to this project will be documented in this file. StatefulSets created by older operator versions cannot be updated in place: after the operator upgrade, delete each metastore StatefulSet so that the operator immediately recreates it with the new labels ([#748]). -- Make operations infallible where dependent on static inputs ([#759]). +- Make operations infallible where dependent on static inputs ([#759], [#764]). ### Fixed @@ -44,6 +44,7 @@ All notable changes to this project will be documented in this file. [#748]: https://github.com/stackabletech/hive-operator/pull/748 [#754]: https://github.com/stackabletech/hive-operator/pull/754 [#759]: https://github.com/stackabletech/hive-operator/pull/759 +[#764]: https://github.com/stackabletech/hive-operator/pull/764 ## [26.7.0] - 2026-07-21 diff --git a/rust/operator-binary/src/controller/build/resource/statefulset.rs b/rust/operator-binary/src/controller/build/resource/statefulset.rs index f82e6094..5ef78b60 100644 --- a/rust/operator-binary/src/controller/build/resource/statefulset.rs +++ b/rust/operator-binary/src/controller/build/resource/statefulset.rs @@ -167,7 +167,7 @@ pub(crate) fn build_metastore_rolegroup_statefulset( let merged_config = &rg.config; let hive_opa_config = cluster.cluster_config.hive_opa_config.as_ref(); - let mut container_builder = new_container_builder(&Container::Hive.to_container_name()); + let mut container_builder = new_container_builder(Container::Hive.name()); // Operator-set env vars first; the user's `envOverrides` are merged on top last and win. let mut env = EnvVarSet::new() @@ -455,7 +455,7 @@ pub(crate) fn build_metastore_rolegroup_statefulset( // default, is started first and can provide any dependencies that vector expects if let Some(vector_log_config) = &rg.config.logging.vector_container { pod_builder.add_container(vector_container( - &Container::Vector.to_container_name(), + Container::Vector.name(), resolved_product_image, vector_log_config, &resource_names, @@ -612,7 +612,7 @@ mod tests { .expect("the pod template has a spec") .containers .into_iter() - .find(|container| container.name == Container::Hive.to_container_name().to_string()) + .find(|container| container.name == Container::Hive.name().to_string()) .expect("the hive container exists") .env .expect("the hive container has env vars") diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs index f89ee893..19ba251a 100644 --- a/rust/operator-binary/src/crd/mod.rs +++ b/rust/operator-binary/src/crd/mod.rs @@ -293,11 +293,18 @@ pub enum Container { Vector, } +// Typed container names. They must match the strum `Display` (kebab-case) of the variants above, +// which is pinned by a unit test. +constant!(HIVE_CONTAINER_NAME: ContainerName = "hive"); +constant!(VECTOR_CONTAINER_NAME: ContainerName = "vector"); + impl Container { - /// The type-safe container name for this variant (matching its kebab-case serialization). - pub fn to_container_name(&self) -> ContainerName { - ContainerName::from_str(&self.to_string()) - .expect("a Container variant name is a valid container name") + /// The typed container name of this variant. + pub fn name(&self) -> &'static ContainerName { + match self { + Container::Hive => &HIVE_CONTAINER_NAME, + Container::Vector => &VECTOR_CONTAINER_NAME, + } } } @@ -396,6 +403,7 @@ pub struct HiveClusterStatus { #[cfg(test)] mod tests { use stackable_operator::versioned::test_utils::RoundtripTestData; + use strum::IntoEnumIterator; use super::*; @@ -408,6 +416,17 @@ mod tests { let _ = *STACKABLE_CONFIG_MOUNT_DIR_NAME; let _ = *STACKABLE_LOG_DIR_NAME; let _ = *STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME; + let _ = *HIVE_CONTAINER_NAME; + let _ = *VECTOR_CONTAINER_NAME; + } + + /// The typed container names returned by `name` must agree with the strum `Display` + /// of `Container`, which the logging configuration still uses as the per-container key. + #[test] + fn container_names_match_display() { + for container in Container::iter() { + assert_eq!(container.name().to_string(), container.to_string()); + } } impl RoundtripTestData for v1alpha1::HiveClusterSpec {