Skip to content

Commit 1fbadf2

Browse files
committed
refactor: use v2 metrics helper
1 parent 2e15cce commit 1fbadf2

2 files changed

Lines changed: 10 additions & 19 deletions

File tree

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ pub fn build_rolegroup_metrics_service(
5050
Service {
5151
metadata: ObjectMetaBuilder::new()
5252
.name_and_namespace(cluster)
53-
.name(metrics_service_name(cluster, role_group_name))
53+
.name(
54+
cluster
55+
.resource_names(role_group_name)
56+
.metrics_service_name()
57+
.to_string(),
58+
)
5459
.ownerreference(ownerreference_from_resource(cluster, None, Some(true)))
5560
.with_labels(cluster.recommended_labels(role_group_name))
5661
.with_labels(prometheus_labels())
@@ -69,21 +74,6 @@ pub fn build_rolegroup_metrics_service(
6974
}
7075
}
7176

72-
/// The name of the rolegroup metrics [`Service`] (`<cluster>-<role>-<rolegroup>-metrics`).
73-
///
74-
/// [`ResourceNames`](stackable_operator::v2::role_group_utils::ResourceNames) has no metrics
75-
/// service name, so it is derived from the qualified role-group name (which equals the StatefulSet
76-
/// name) here, preserving the previous `RoleGroupRef::rolegroup_metrics_service_name` output.
77-
pub(crate) fn metrics_service_name(
78-
cluster: &ValidatedCluster,
79-
role_group_name: &RoleGroupName,
80-
) -> String {
81-
format!(
82-
"{qualified}-metrics",
83-
qualified = cluster.resource_names(role_group_name).stateful_set_name()
84-
)
85-
}
86-
8777
fn headless_service_ports() -> Vec<ServicePort> {
8878
vec![ServicePort {
8979
name: Some(HTTPS_PORT_NAME.into()),

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,10 @@ pub(crate) async fn build_node_rolegroup_statefulset(
611611
&cluster.cluster_config.server_tls_secret_class,
612612
KEYSTORE_VOLUME_NAME,
613613
[
614-
crate::controller::build::resource::service::metrics_service_name(
615-
cluster, &rg.name,
616-
),
614+
cluster
615+
.resource_names(&rg.name)
616+
.metrics_service_name()
617+
.to_string(),
617618
build_reporting_task_service_name(&nifi_cluster_name),
618619
],
619620
SecretFormat::TlsPkcs12,

0 commit comments

Comments
 (0)