Skip to content

Commit cb85a6a

Browse files
committed
review feedback: remove metrics port and re-work conditions
1 parent f9c41bc commit cb85a6a

2 files changed

Lines changed: 35 additions & 30 deletions

File tree

rust/operator-binary/src/airflow_controller.rs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -511,16 +511,21 @@ pub async fn reconcile_airflow(
511511
if let Some(listener_class) =
512512
airflow.merged_listener_class(&airflow_role, &rolegroup.role_group)
513513
{
514-
let rg_group_listener = build_group_listener(
515-
airflow,
516-
&resolved_product_image,
517-
&rolegroup,
518-
listener_class.to_string(),
519-
)?;
520-
cluster_resources
521-
.add(client, rg_group_listener)
522-
.await
523-
.context(ApplyGroupListenerSnafu)?;
514+
if let Some(listener_group_name) =
515+
airflow.group_listener_name(&airflow_role, &rolegroup)
516+
{
517+
let rg_group_listener = build_group_listener(
518+
airflow,
519+
&resolved_product_image,
520+
&rolegroup,
521+
listener_class.to_string(),
522+
listener_group_name,
523+
)?;
524+
cluster_resources
525+
.add(client, rg_group_listener)
526+
.await
527+
.context(ApplyGroupListenerSnafu)?;
528+
}
524529
}
525530

526531
ss_cond_builder.add(
@@ -832,11 +837,12 @@ pub fn build_group_listener(
832837
resolved_product_image: &ResolvedProductImage,
833838
rolegroup: &RoleGroupRef<v1alpha1::AirflowCluster>,
834839
listener_class: String,
840+
listener_group_name: String,
835841
) -> Result<Listener> {
836842
Ok(Listener {
837843
metadata: ObjectMetaBuilder::new()
838844
.name_and_namespace(airflow)
839-
.name(airflow.group_listener_name(rolegroup))
845+
.name(listener_group_name)
840846
.ownerreference_from_resource(airflow, None, Some(true))
841847
.context(ObjectMissingMetadataForOwnerRefSnafu)?
842848
.with_recommended_labels(build_recommended_labels(
@@ -857,19 +863,14 @@ pub fn build_group_listener(
857863
})
858864
}
859865

866+
/// We only use the http port here and intentionally omit
867+
/// the metrics one.
860868
fn listener_ports() -> Vec<ListenerPort> {
861-
vec![
862-
ListenerPort {
863-
name: METRICS_PORT_NAME.to_string(),
864-
port: METRICS_PORT.into(),
865-
protocol: Some("TCP".to_string()),
866-
},
867-
ListenerPort {
868-
name: HTTP_PORT_NAME.to_string(),
869-
port: HTTP_PORT.into(),
870-
protocol: Some("TCP".to_string()),
871-
},
872-
]
869+
vec![ListenerPort {
870+
name: HTTP_PORT_NAME.to_string(),
871+
port: HTTP_PORT.into(),
872+
protocol: Some("TCP".to_string()),
873+
}]
873874
}
874875

875876
/// The rolegroup [`StatefulSet`] runs the rolegroup, as configured by the administrator.
@@ -1007,16 +1008,13 @@ fn build_server_rolegroup_statefulset(
10071008

10081009
let mut pvcs: Option<Vec<PersistentVolumeClaim>> = None;
10091010

1010-
if airflow
1011-
.merged_listener_class(airflow_role, &rolegroup_ref.role_group)
1012-
.is_some()
1013-
{
1011+
if let Some(listener_group_name) = airflow.group_listener_name(airflow_role, rolegroup_ref) {
10141012
// Listener endpoints for the Webserver role will use persistent volumes
10151013
// so that load balancers can hard-code the target addresses. This will
10161014
// be the case even when no class is set (and the value defaults to
10171015
// cluster-internal) as the address should still be consistent.
10181016
let pvc = ListenerOperatorVolumeSourceBuilder::new(
1019-
&ListenerReference::ListenerName(airflow.group_listener_name(rolegroup_ref)),
1017+
&ListenerReference::ListenerName(listener_group_name),
10201018
&unversioned_recommended_labels,
10211019
)
10221020
.context(BuildListenerVolumeSnafu)?

rust/operator-binary/src/crd/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,15 @@ impl v1alpha1::AirflowCluster {
282282
/// The name of the group-listener provided for a specific role-group.
283283
/// Webservers will use this group listener so that only one load balancer
284284
/// is needed (per role group).
285-
pub fn group_listener_name(&self, rolegroup: &RoleGroupRef<Self>) -> String {
286-
format!("{}-group", rolegroup.object_name())
285+
pub fn group_listener_name(
286+
&self,
287+
role: &AirflowRole,
288+
rolegroup: &RoleGroupRef<Self>,
289+
) -> Option<String> {
290+
match role {
291+
AirflowRole::Webserver => Some(format!("{}-group", rolegroup.object_name())),
292+
AirflowRole::Scheduler | AirflowRole::Worker => None,
293+
}
287294
}
288295

289296
/// the worker role will not be returned if airflow provisions pods as needed (i.e. when

0 commit comments

Comments
 (0)