Skip to content

Commit bd74c66

Browse files
committed
fix: use framework metrics service; use framework log dir; remove stale comments
1 parent d1e9dc9 commit bd74c66

4 files changed

Lines changed: 20 additions & 26 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ type Result<T, E = Error> = std::result::Result<T, E>;
3434
/// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the
3535
/// administrator.
3636
///
37-
/// `vector_config` is the Vector agent config (`vector.yaml`) built by the caller (where a
38-
/// `RoleGroupRef` is available); it is `None` when the Vector agent is disabled.
37+
/// `vector_config` is the Vector agent config (`vector.yaml`) built by the caller; it is `None`
38+
/// when the Vector agent is disabled.
3939
pub fn build_rolegroup_config_map(
4040
cluster: &ValidatedCluster,
4141
role_group_name: &RoleGroupName,

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use stackable_operator::{
5151
meta::ownerreference_from_resource,
5252
pod::container::{EnvVarSet, new_container_builder},
5353
},
54-
product_logging::framework::vector_container,
54+
product_logging::framework::{STACKABLE_LOG_DIR, vector_container},
5555
types::{
5656
common::Port,
5757
kubernetes::{ContainerName, VolumeName},
@@ -76,7 +76,6 @@ pub const BUNDLE_BUILDER_PORT: Port = Port(3030);
7676
stackable_operator::constant!(CONFIG_VOLUME_NAME: VolumeName = "config");
7777
const CONFIG_DIR: &str = "/stackable/config";
7878
stackable_operator::constant!(LOG_VOLUME_NAME: VolumeName = "log");
79-
const STACKABLE_LOG_DIR: &str = "/stackable/log";
8079
stackable_operator::constant!(BUNDLES_VOLUME_NAME: VolumeName = "bundles");
8180
const BUNDLES_DIR: &str = "/bundles";
8281
stackable_operator::constant!(USER_INFO_FETCHER_CREDENTIALS_VOLUME_NAME: VolumeName = "credentials");
@@ -427,7 +426,12 @@ pub fn build_server_rolegroup_daemonset(
427426
.headless_service_name()
428427
.to_string(),
429428
)
430-
.with_service_scope(service::metrics_service_name(cluster, role_group_name))
429+
.with_service_scope(
430+
cluster
431+
.resource_names(role_group_name)
432+
.metrics_service_name()
433+
.to_string(),
434+
)
431435
.build()
432436
.context(TlsVolumeBuildSnafu)?,
433437
)

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ pub(crate) fn build_rolegroup_metrics_service(
117117
let tls_enabled = cluster.cluster_config.tls.is_some();
118118
let metadata = ObjectMetaBuilder::new()
119119
.name_and_namespace(cluster)
120-
.name(metrics_service_name(cluster, role_group_name))
120+
.name(
121+
cluster
122+
.resource_names(role_group_name)
123+
.metrics_service_name()
124+
.to_string(),
125+
)
121126
.ownerreference(ownerreference_from_resource(cluster, None, Some(true)))
122127
.with_labels(cluster.recommended_labels(role_group_name))
123128
.with_labels(prometheus_labels())
@@ -137,21 +142,6 @@ pub(crate) fn build_rolegroup_metrics_service(
137142
}
138143
}
139144

140-
/// The metrics [`Service`] name, `<cluster>-<role>-<rolegroup>-metrics`.
141-
///
142-
/// [`ResourceNames`](stackable_operator::v2::role_group_utils::ResourceNames) has no metrics
143-
/// service helper, so the `-metrics` suffix is appended to the qualified role-group name (which is
144-
/// also the StatefulSet/DaemonSet name).
145-
pub(crate) fn metrics_service_name(
146-
cluster: &ValidatedCluster,
147-
role_group_name: &RoleGroupName,
148-
) -> String {
149-
format!(
150-
"{qualified}-metrics",
151-
qualified = cluster.resource_names(role_group_name).stateful_set_name()
152-
)
153-
}
154-
155145
fn data_service_ports(tls_enabled: bool) -> Vec<ServicePort> {
156146
let (port_name, port) = if tls_enabled {
157147
(APP_TLS_PORT_NAME, APP_TLS_PORT)

rust/operator-binary/src/controller/validate.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ type Result<T, E = Error> = std::result::Result<T, E>;
8282

8383
/// Validated logging configuration for a role group.
8484
///
85-
/// Produced up-front by [`validate_logging`] (mirroring hive/opensearch) so that a missing or
86-
/// invalid Vector aggregator discovery ConfigMap name fails reconciliation during validation
87-
/// rather than at resource-build time.
85+
/// Produced up-front by [`validate_logging`] so that a missing or invalid Vector aggregator
86+
/// discovery ConfigMap name fails reconciliation during validation rather than at
87+
/// resource-build time.
8888
#[derive(Clone, Debug, PartialEq, Eq)]
8989
pub struct ValidatedLogging {
9090
/// The validated Vector container config, or `None` when the Vector agent is disabled.
@@ -165,7 +165,7 @@ pub fn validate(
165165
)?;
166166

167167
// The framework keeps `envOverrides` as a `HashMap<String, String>`; lift it into the
168-
// type-safe `EnvVarSet` so the build step matches opensearch/hive.
168+
// type-safe `EnvVarSet` consumed by the build step.
169169
let mut env_overrides = EnvVarSet::new();
170170
for (name, value) in merged.config.env_overrides {
171171
env_overrides = env_overrides.with_value(
@@ -194,7 +194,7 @@ pub fn validate(
194194
ValidatedRoleGroup {
195195
config: OpaRoleGroupConfig {
196196
// Unused for a DaemonSet, but the framework type requires it.
197-
replicas: merged.replicas.unwrap_or(0),
197+
replicas: merged.replicas,
198198
config: merged.config.config,
199199
config_overrides: merged.config.config_overrides,
200200
env_overrides,

0 commit comments

Comments
 (0)