Skip to content

Commit f68f423

Browse files
committed
use listener scope for server tls cert
1 parent 8b7ed00 commit f68f423

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use crate::{
9191
},
9292
listener::{
9393
LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, build_group_listener, build_group_listener_pvc,
94-
group_listener_name,
94+
group_listener_name, secret_volume_listener_scope,
9595
},
9696
operations::{
9797
add_graceful_shutdown_config, graceful_shutdown_config_properties, pdb::add_pdbs,
@@ -964,18 +964,15 @@ fn build_rolegroup_statefulset(
964964
.requested_secret_lifetime
965965
.context(MissingSecretLifetimeSnafu)?;
966966

967-
let extra_service_scopes = group_listener_name(trino, trino_role)
968-
.map(|listener_service_name| vec![listener_service_name]);
969-
970967
// add volume mounts depending on the client tls, internal tls, catalogs and authentication
971968
tls_volume_mounts(
972969
trino,
970+
trino_role,
973971
&mut pod_builder,
974972
&mut cb_prepare,
975973
&mut cb_trino,
976974
catalogs,
977975
&requested_secret_lifetime,
978-
extra_service_scopes,
979976
)?;
980977

981978
let mut prepare_args = vec![];
@@ -1515,20 +1512,17 @@ fn create_tls_volume(
15151512
volume_name: &str,
15161513
tls_secret_class: &str,
15171514
requested_secret_lifetime: &Duration,
1518-
service_scopes: Option<Vec<String>>,
1515+
listener_scope: Option<String>,
15191516
) -> Result<Volume> {
15201517
let mut secret_volume_source_builder = SecretOperatorVolumeSourceBuilder::new(tls_secret_class);
15211518

15221519
secret_volume_source_builder
15231520
.with_pod_scope()
1524-
.with_node_scope()
15251521
.with_format(SecretFormat::TlsPkcs12)
15261522
.with_auto_tls_cert_lifetime(*requested_secret_lifetime);
15271523

1528-
if let Some(scopes) = &service_scopes {
1529-
for scope in scopes {
1530-
secret_volume_source_builder.with_service_scope(scope);
1531-
}
1524+
if let Some(listener_scope) = &listener_scope {
1525+
secret_volume_source_builder.with_listener_volume_scope(listener_scope);
15321526
}
15331527

15341528
Ok(VolumeBuilder::new(volume_name)
@@ -1542,12 +1536,12 @@ fn create_tls_volume(
15421536

15431537
fn tls_volume_mounts(
15441538
trino: &v1alpha1::TrinoCluster,
1539+
trino_role: &TrinoRole,
15451540
pod_builder: &mut PodBuilder,
15461541
cb_prepare: &mut ContainerBuilder,
15471542
cb_trino: &mut ContainerBuilder,
15481543
catalogs: &[CatalogConfig],
15491544
requested_secret_lifetime: &Duration,
1550-
extra_service_scopes: Option<Vec<String>>,
15511545
) -> Result<()> {
15521546
if let Some(server_tls) = trino.get_server_tls() {
15531547
cb_prepare
@@ -1562,7 +1556,7 @@ fn tls_volume_mounts(
15621556
server_tls,
15631557
requested_secret_lifetime,
15641558
// add listener
1565-
extra_service_scopes,
1559+
secret_volume_listener_scope(trino_role),
15661560
)?)
15671561
.context(AddVolumeSnafu)?;
15681562
}

rust/operator-binary/src/listener.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ pub fn group_listener_name(trino: &v1alpha1::TrinoCluster, role: &TrinoRole) ->
8383
}
8484
}
8585

86+
/// The listener volume name depending on the role
87+
pub fn secret_volume_listener_scope(role: &TrinoRole) -> Option<String> {
88+
match role {
89+
TrinoRole::Coordinator => Some(LISTENER_VOLUME_NAME.to_string()),
90+
TrinoRole::Worker => None,
91+
}
92+
}
93+
8694
/// We only use the http/https port here and intentionally omit the metrics one.
8795
fn listener_ports(trino: &v1alpha1::TrinoCluster) -> Vec<ListenerPort> {
8896
let name = trino.exposed_protocol().to_string();

0 commit comments

Comments
 (0)