Skip to content

Fix: headless svc for all roles as connection requires #653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions rust/operator-binary/src/airflow_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,23 +514,20 @@ pub async fn reconcile_airflow(
)
.context(LabelBuildSnafu)?;

// Only apply headless service for something exposing an HTTP port
if airflow_role.get_http_port().is_some() {
let rg_headless_service = build_rolegroup_headless_service(
airflow,
&rolegroup,
role_group_service_recommended_labels.clone(),
role_group_service_selector.clone().into(),
)
.context(ServiceConfigurationSnafu)?;
let rg_headless_service = build_rolegroup_headless_service(
airflow,
&rolegroup,
role_group_service_recommended_labels.clone(),
role_group_service_selector.clone().into(),
)
.context(ServiceConfigurationSnafu)?;

cluster_resources
.add(client, rg_headless_service)
.await
.context(ApplyRoleGroupServiceSnafu {
rolegroup: rolegroup.clone(),
})?;
}
cluster_resources
.add(client, rg_headless_service)
.await
.context(ApplyRoleGroupServiceSnafu {
rolegroup: rolegroup.clone(),
})?;

let rg_metrics_service = build_rolegroup_metrics_service(
airflow,
Expand Down Expand Up @@ -1159,7 +1156,7 @@ fn build_server_rolegroup_statefulset(
match_labels: Some(statefulset_match_labels.into()),
..LabelSelector::default()
},
service_name: stateful_set_service_name(airflow_role, rolegroup_ref),
service_name: stateful_set_service_name(rolegroup_ref),
template: pod_template,
volume_claim_templates: pvcs,
..StatefulSetSpec::default()
Expand Down
14 changes: 4 additions & 10 deletions rust/operator-binary/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use stackable_operator::{
role_utils::RoleGroupRef,
};

use crate::crd::{
AirflowRole, HTTP_PORT, HTTP_PORT_NAME, METRICS_PORT, METRICS_PORT_NAME, v1alpha1,
};
use crate::crd::{HTTP_PORT, HTTP_PORT_NAME, METRICS_PORT, METRICS_PORT_NAME, v1alpha1};

pub const METRICS_SERVICE_SUFFIX: &str = "metrics";
pub const HEADLESS_SERVICE_SUFFIX: &str = "headless";
Expand Down Expand Up @@ -111,15 +109,11 @@ pub fn build_rolegroup_metrics_service(
}

pub fn stateful_set_service_name(
airflow_role: &AirflowRole,
rolegroup_ref: &RoleGroupRef<v1alpha1::AirflowCluster>,
) -> Option<String> {
match airflow_role {
AirflowRole::Webserver => Some(rolegroup_headless_service_name(
&rolegroup_ref.object_name(),
)),
AirflowRole::Scheduler | AirflowRole::Worker => None,
}
Some(rolegroup_headless_service_name(
&rolegroup_ref.object_name(),
))
}

/// Returns the metrics rolegroup service name `<cluster>-<role>-<rolegroup>-<METRICS_SERVICE_SUFFIX>`.
Expand Down