From f89b709b281f33d61e9f4ebfb62aad1dd635f665 Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy Date: Thu, 10 Sep 2026 17:17:59 +0200 Subject: [PATCH 1/2] fix: make container name accessor infallible --- .../src/controller/build/resource/mod.rs | 6 ++-- rust/operator-binary/src/crd/mod.rs | 28 +++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/rust/operator-binary/src/controller/build/resource/mod.rs b/rust/operator-binary/src/controller/build/resource/mod.rs index d186bbce..c07af455 100644 --- a/rust/operator-binary/src/controller/build/resource/mod.rs +++ b/rust/operator-binary/src/controller/build/resource/mod.rs @@ -80,6 +80,8 @@ const STACKABLE_CERTS_DIR: &str = "/stackable/certs/"; /// Path of the statsd-exporter binary launched by the `metrics` sidecar. const STATSD_EXPORTER_BINARY: &str = "/stackable/statsd_exporter"; +// The metrics container has no logging configuration, so it is not a `Container` variant and +// carries its name directly. constant!(METRICS_CONTAINER_NAME: ContainerName = "metrics"); // Name of the listener volume. It is a PVC, so the same name is used as the volume/mount name and @@ -255,7 +257,7 @@ pub(crate) fn build_superset_container_builder( rolegroup_config: &SupersetRoleGroupConfig, role_specific_env_vars: EnvVarSet, ) -> ContainerBuilder { - let mut superset_cb = new_container_builder(&Container::Superset.to_container_name()); + let mut superset_cb = new_container_builder(Container::Superset.name()); superset_cb .image_from_product_image(&validated.image) @@ -315,7 +317,7 @@ pub(crate) fn build_vector_container( .as_ref() .map(|vector_log_config| { vector_container( - &Container::Vector.to_container_name(), + Container::Vector.name(), &validated.image, vector_log_config, &validated.role_group_resource_names(superset_role, role_group_name), diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs index 84c13b91..639aecb0 100644 --- a/rust/operator-binary/src/crd/mod.rs +++ b/rust/operator-binary/src/crd/mod.rs @@ -460,11 +460,18 @@ impl From<&SupersetRole> for RoleName { } } +// Typed container names. They must match the strum `Display` (kebab-case) of the +// `v1alpha1::Container` variants, which is pinned by a unit test. +constant!(SUPERSET_CONTAINER_NAME: ContainerName = "superset"); +constant!(VECTOR_CONTAINER_NAME: ContainerName = "vector"); + impl v1alpha1::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 { + v1alpha1::Container::Superset => &SUPERSET_CONTAINER_NAME, + v1alpha1::Container::Vector => &VECTOR_CONTAINER_NAME, + } } } @@ -635,9 +642,18 @@ mod tests { use super::{ BEAT_ROLE_NAME, ClusterName, DEFAULT_LISTENER_CLASS, INTERNAL_SECRET_SECRET_KEY, MAPBOX_API_KEY_ENV, MAPBOX_API_KEY_SECRET_KEY, NODE_ROLE_NAME, SECRET_KEY_ENV, - SupersetRole, WORKER_ROLE_NAME, v1alpha1, + SUPERSET_CONTAINER_NAME, SupersetRole, VECTOR_CONTAINER_NAME, WORKER_ROLE_NAME, v1alpha1, }; + /// The typed container names returned by `name` must agree with the strum `Display` of + /// `v1alpha1::Container`, which the logging configuration still uses as the per-container key. + #[test] + fn container_names_match_display() { + for container in v1alpha1::Container::iter() { + assert_eq!(container.name().to_string(), container.to_string()); + } + } + #[test] fn test_constants() { // Test that dereferencing the constants does not panic. @@ -645,6 +661,8 @@ mod tests { let _ = *NODE_ROLE_NAME; let _ = *WORKER_ROLE_NAME; let _ = *BEAT_ROLE_NAME; + let _ = *SUPERSET_CONTAINER_NAME; + let _ = *VECTOR_CONTAINER_NAME; let _ = *SECRET_KEY_ENV; let _ = *INTERNAL_SECRET_SECRET_KEY; let _ = *MAPBOX_API_KEY_ENV; From 92bc48d9d4f16c01a13b90a5ad0479e8119e636c Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy Date: Thu, 10 Sep 2026 17:20:36 +0200 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bae9ea9..53364b7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ Since `volumeClaimTemplates` cannot be updated in place, StatefulSets created by older operator versions cannot be updated after the upgrade: delete the `node` StatefulSet(s) so that the operator immediately recreates them with the new labels ([#779]). -- Make operations infallible where dependent on static inputs ([#785]). +- Make operations infallible where dependent on static inputs ([#785], [#788]). ### Removed @@ -49,6 +49,7 @@ [#779]: https://github.com/stackabletech/superset-operator/pull/779 [#781]: https://github.com/stackabletech/superset-operator/pull/781 [#785]: https://github.com/stackabletech/superset-operator/pull/785 +[#788]: https://github.com/stackabletech/superset-operator/pull/788 ## [26.7.0] - 2026-07-21