Skip to content

Commit aac7580

Browse files
committed
remove headless service from worker
1 parent 1933125 commit aac7580

3 files changed

Lines changed: 35 additions & 24 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,20 @@ pub async fn reconcile_trino(
500500
)
501501
.context(LabelBuildSnafu)?;
502502

503-
let rg_headless_service = build_rolegroup_headless_service(
504-
trino,
505-
&role_group_ref,
506-
role_group_service_recommended_labels.clone(),
507-
role_group_service_selector.clone().into(),
508-
)
509-
.context(ServiceConfigurationSnafu)?;
503+
let rg_headless_service = if trino_role.requires_headless_service() {
504+
Some(
505+
build_rolegroup_headless_service(
506+
trino,
507+
&role_group_ref,
508+
role_group_service_recommended_labels.clone(),
509+
role_group_service_selector.clone().into(),
510+
)
511+
.context(ServiceConfigurationSnafu)?,
512+
)
513+
} else {
514+
None
515+
};
516+
510517
let rg_metrics_service = build_rolegroup_metrics_service(
511518
trino,
512519
&role_group_ref,
@@ -545,12 +552,14 @@ pub async fn reconcile_trino(
545552
&rbac_sa.name_any(),
546553
)?;
547554

548-
cluster_resources
549-
.add(client, rg_headless_service)
550-
.await
551-
.with_context(|_| ApplyRoleGroupServiceSnafu {
552-
rolegroup: role_group_ref.clone(),
553-
})?;
555+
if let Some(rg_headless_service) = rg_headless_service {
556+
cluster_resources
557+
.add(client, rg_headless_service)
558+
.await
559+
.with_context(|_| ApplyRoleGroupServiceSnafu {
560+
rolegroup: role_group_ref.clone(),
561+
})?;
562+
}
554563
cluster_resources
555564
.add(client, rg_metrics_service)
556565
.await
@@ -1197,6 +1206,13 @@ fn build_rolegroup_statefulset(
11971206
.service_account_name(sa_name)
11981207
.security_context(PodSecurityContextBuilder::new().fs_group(1000).build());
11991208

1209+
let service_name = if trino_role.requires_headless_service() {
1210+
Some(rolegroup_headless_service_name(
1211+
&role_group_ref.object_name(),
1212+
))
1213+
} else {
1214+
None
1215+
};
12001216
let mut pod_template = pod_builder.build_template();
12011217
pod_template.merge_from(role.config.pod_overrides.clone());
12021218
pod_template.merge_from(rolegroup.config.pod_overrides.clone());
@@ -1231,9 +1247,7 @@ fn build_rolegroup_statefulset(
12311247
),
12321248
..LabelSelector::default()
12331249
},
1234-
service_name: Some(rolegroup_headless_service_name(
1235-
&role_group_ref.object_name(),
1236-
)),
1250+
service_name,
12371251
template: pod_template,
12381252
volume_claim_templates: Some(persistent_volume_claims),
12391253
..StatefulSetSpec::default()

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ impl TrinoRole {
427427
Self::Worker => None,
428428
}
429429
}
430+
431+
pub fn requires_headless_service(&self) -> bool {
432+
self == &Self::Coordinator
433+
}
430434
}
431435

432436
#[derive(

tests/templates/kuttl/listener/10-assert.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,7 @@ spec:
6060
---
6161
apiVersion: v1
6262
kind: Service
63-
metadata:
64-
name: test-trino-worker-default-headless
65-
spec:
66-
type: ClusterIP # by trino op
67-
---
68-
apiVersion: v1
69-
kind: Service
7063
metadata:
7164
name: test-trino-worker-default-metrics
7265
spec:
73-
type: ClusterIP # by trino op
66+
type: ClusterIP # by trino op

0 commit comments

Comments
 (0)