Skip to content

Commit 79a1930

Browse files
committed
remove hardcoded role name
1 parent 3c7850f commit 79a1930

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,11 +578,14 @@ pub async fn reconcile_nifi(
578578
.await
579579
.context(FailedToCreatePdbSnafu)?;
580580

581+
let role_name = match &nifi_role {
582+
NifiRole::Node => "node".to_string(),
583+
};
581584
let role_group_listener = build_group_listener(
582585
nifi,
583586
build_recommended_labels(nifi, NIFI_CONTROLLER_NAME, &nifi_role.to_string(), "none"),
584587
listener_class.to_owned(),
585-
group_listener_name(nifi),
588+
group_listener_name(nifi, &role_name),
586589
)
587590
.context(ListenerConfigurationSnafu)?;
588591

@@ -933,14 +936,14 @@ async fn build_node_rolegroup_statefulset(
933936
env_vars.extend(authorization_config.get_env_vars());
934937

935938
let node_address = format!(
936-
"$POD_NAME.{}.{}.svc.{}",
937-
rolegroup_service_name(rolegroup_ref),
938-
&nifi
939+
"$POD_NAME.{service_name}.{namespace}.svc.{cluster_domain}",
940+
service_name = rolegroup_service_name(rolegroup_ref),
941+
namespace = &nifi
939942
.metadata
940943
.namespace
941944
.as_ref()
942945
.context(ObjectHasNoNamespaceSnafu)?,
943-
cluster_info.cluster_domain,
946+
cluster_domain = cluster_info.cluster_domain,
944947
);
945948

946949
let sensitive_key_secret = &nifi.spec.cluster_config.sensitive_properties.key_secret;
@@ -1191,9 +1194,11 @@ async fn build_node_rolegroup_statefulset(
11911194
// listener endpoints will use persistent volumes
11921195
// so that load balancers can hard-code the target addresses and
11931196
// that it is possible to connect to a consistent address
1194-
let listener_pvc =
1195-
build_group_listener_pvc(&group_listener_name(nifi), &unversioned_recommended_labels)
1196-
.context(ListenerConfigurationSnafu)?;
1197+
let listener_pvc = build_group_listener_pvc(
1198+
&group_listener_name(nifi, &rolegroup_ref.role),
1199+
&unversioned_recommended_labels,
1200+
)
1201+
.context(ListenerConfigurationSnafu)?;
11971202

11981203
add_graceful_shutdown_config(merged_config, &mut pod_builder).context(GracefulShutdownSnafu)?;
11991204

rust/operator-binary/src/listener.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ pub fn build_group_listener_pvc(
7474
.context(BuildListenerPersistentVolumeSnafu)
7575
}
7676

77-
pub fn group_listener_name(nifi: &v1alpha1::NifiCluster) -> String {
78-
format!("{cluster_name}-node", cluster_name = nifi.name_any())
77+
pub fn group_listener_name(nifi: &v1alpha1::NifiCluster, role_name: &String) -> String {
78+
format!("{cluster_name}-{role_name}", cluster_name = nifi.name_any(),)
7979
}

0 commit comments

Comments
 (0)