Skip to content
Draft
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ All notable changes to this project will be documented in this file.
delete each coordinator StatefulSet so that the operator immediately recreates it with the
new labels ([#932]).
- Make operations infallible where dependent on static inputs ([#939], [#943]).
- Internal operator refactoring: the validated cluster carries each role's configuration in its own
typed fields instead of maps keyed by role, and the coordinator's role config is no longer
converted to the worker's shape and its listener class recovered afterwards ([#945]).

### Fixed

Expand All @@ -49,6 +52,7 @@ All notable changes to this project will be documented in this file.
[#934]: https://github.com/stackabletech/trino-operator/pull/934
[#939]: https://github.com/stackabletech/trino-operator/pull/939
[#943]: https://github.com/stackabletech/trino-operator/pull/943
[#945]: https://github.com/stackabletech/trino-operator/pull/945

## [26.7.0] - 2026-07-21

Expand Down
38 changes: 22 additions & 16 deletions rust/operator-binary/src/controller/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::{
statefulset,
},
},
crd::TrinoRole,
trino_controller::{CONTROLLER_NAME, OPERATOR_NAME, PRODUCT_NAME},
};

Expand Down Expand Up @@ -68,7 +69,16 @@ pub fn build(
let mut config_maps = vec![];
let mut pod_disruption_budgets = vec![];

for (role, role_group_configs) in &cluster.role_group_configs {
// One entry per role, in `TrinoRole` declaration order. Each role's groups come from its own
// field, so the role and its groups cannot be paired up wrongly here.
for (role, role_group_configs) in [
(
TrinoRole::Coordinator,
&cluster.coordinator_role_group_configs,
),
(TrinoRole::Worker, &cluster.worker_role_group_configs),
] {
let role: &TrinoRole = &role;
for (role_group_name, role_group_config) in role_group_configs {
let selector = role_group_selector(cluster, role, role_group_name);

Expand Down Expand Up @@ -115,22 +125,18 @@ pub fn build(
);
}

let Some(role_config) = cluster.role_config(role) else {
continue;
};

if let Some(listener_class) = &role_config.listener_class
&& let Some(listener_group_name) = group_listener_name(cluster, role)
{
listeners.push(build_group_listener(
cluster,
role,
listener_class,
&listener_group_name,
));
}
pod_disruption_budgets.extend(build_pdb(cluster.pdb(role), cluster, role));
}

pod_disruption_budgets.extend(build_pdb(&role_config.pdb, cluster, role));
// Only the coordinator has a group listener, so it is built once here rather than inside the
// role loop.
if let Some(listener_group_name) = group_listener_name(cluster, &TrinoRole::Coordinator) {
listeners.push(build_group_listener(
cluster,
&TrinoRole::Coordinator,
&cluster.coordinator_config.listener_class,
&listener_group_name,
));
}

Ok(KubernetesResources {
Expand Down
15 changes: 7 additions & 8 deletions rust/operator-binary/src/controller/build/graceful_shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,13 @@ pub fn graceful_shutdown_config_properties(
}
}

/// Returns the minimal `gracefulShutdownTimeout` across all worker role-groups, read from the
/// validated [`ValidatedCluster::role_group_configs`].
/// Returns the minimal `gracefulShutdownTimeout` across all worker role-groups
fn min_worker_graceful_shutdown_timeout(
cluster: &ValidatedCluster,
) -> stackable_operator::shared::time::Duration {
cluster
.role_group_configs
.get(&TrinoRole::Worker)
.into_iter()
.flat_map(|groups| groups.values())
.worker_role_group_configs
.values()
.filter_map(|rg| rg.config.graceful_shutdown_timeout)
.min()
.unwrap_or(DEFAULT_WORKER_GRACEFUL_SHUTDOWN_TIMEOUT)
Expand Down Expand Up @@ -309,7 +306,8 @@ mod tests {
#[test]
fn worker_termination_grace_period_adds_overhead_and_sets_pre_stop() {
let cluster = validated_cluster_from_yaml(MINIMAL_TRINO_YAML);
let merged = &cluster.role_group_configs[&TrinoRole::Worker]
let merged = &cluster
.worker_role_group_configs
.values()
.next()
.expect("the fixture defines a worker role group")
Expand Down Expand Up @@ -348,7 +346,8 @@ mod tests {
#[test]
fn coordinator_termination_grace_period_has_no_overhead_or_pre_stop() {
let cluster = validated_cluster_from_yaml(MINIMAL_TRINO_YAML);
let merged = &cluster.role_group_configs[&TrinoRole::Coordinator]
let merged = &cluster
.coordinator_role_group_configs
.values()
.next()
.expect("the fixture defines a coordinator role group")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ pub fn build(cluster: &ValidatedCluster, rg: &TrinoRoleGroupConfig) -> BTreeMap<
#[cfg(test)]
mod tests {
use super::*;
use crate::{
controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
},
crd::TrinoRole,
use crate::controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
};

#[test]
fn default_renders_empty_when_no_opa() {
let cluster = validated_cluster_from_yaml(MINIMAL_TRINO_YAML);
let rg = cluster.role_group_configs[&TrinoRole::Coordinator]
let rg = cluster
.coordinator_role_group_configs
.values()
.next()
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ mod tests {
}

fn rg(cluster: &ValidatedCluster, role: &TrinoRole) -> TrinoRoleGroupConfig {
cluster.role_group_configs[role]
cluster
.role_group_configs(role)
.values()
.next()
.expect("the fixture defines a role group")
Expand All @@ -322,7 +323,8 @@ mod tests {
#[test]
fn default_renders_includes_coordinator_default_and_query_max_memory_default() {
let cluster = validated_cluster_from_yaml(MINIMAL_TRINO_YAML);
let rg = cluster.role_group_configs[&TrinoRole::Coordinator]
let rg = cluster
.coordinator_role_group_configs
.values()
.next()
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ pub fn build(cluster: &ValidatedCluster, rg: &TrinoRoleGroupConfig) -> BTreeMap<
#[cfg(test)]
mod tests {
use super::*;
use crate::{
controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
},
crd::TrinoRole,
use crate::controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
};

#[test]
fn default_renders_empty_when_no_fte() {
let cluster = validated_cluster_from_yaml(MINIMAL_TRINO_YAML);
let rg = cluster.role_group_configs[&TrinoRole::Coordinator]
let rg = cluster
.coordinator_role_group_configs
.values()
.next()
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ pub fn build(rg: &TrinoRoleGroupConfig) -> BTreeMap<String, String> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
},
crd::TrinoRole,
use crate::controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
};

#[test]
fn default_renders_root_logger_only() {
let cluster = validated_cluster_from_yaml(MINIMAL_TRINO_YAML);
let rg = cluster.role_group_configs[&TrinoRole::Coordinator]
let rg = cluster
.coordinator_role_group_configs
.values()
.next()
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ mod tests {
#[test]
fn default_renders_node_environment_from_cluster_name() {
let cluster = validated_cluster_from_yaml(MINIMAL_TRINO_YAML);
let rg = cluster.role_group_configs[&crate::crd::TrinoRole::Coordinator]
let rg = cluster
.coordinator_role_group_configs
.values()
.next()
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ pub fn build(rg: &TrinoRoleGroupConfig) -> BTreeMap<String, String> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
},
crd::TrinoRole,
use crate::controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
};

fn coordinator_rg(
cluster: &crate::controller::ValidatedCluster,
) -> crate::controller::TrinoRoleGroupConfig {
cluster.role_group_configs[&TrinoRole::Coordinator]
cluster
.coordinator_role_group_configs
.values()
.next()
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ pub fn build(cluster: &ValidatedCluster, rg: &TrinoRoleGroupConfig) -> BTreeMap<
#[cfg(test)]
mod tests {
use super::*;
use crate::{
controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
},
crd::TrinoRole,
use crate::controller::build::properties::test_support::{
MINIMAL_TRINO_YAML, validated_cluster_from_yaml,
};

#[test]
fn default_renders_empty_when_no_spooling() {
let cluster = validated_cluster_from_yaml(MINIMAL_TRINO_YAML);
let rg = cluster.role_group_configs[&TrinoRole::Coordinator]
let rg = cluster
.coordinator_role_group_configs
.values()
.next()
.unwrap()
Expand Down
11 changes: 2 additions & 9 deletions rust/operator-binary/src/controller/build/resource/config_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,8 @@ pub fn build_rolegroup_config_map(
role_group_name: &RoleGroupName,
cluster_info: &KubernetesClusterInfo,
) -> Result<ConfigMap> {
let role_group_configs =
cluster
.role_group_configs
.get(role)
.with_context(|| MissingRoleGroupSnafu {
role: role.to_string(),
role_group: role_group_name.to_string(),
})?;
let rg = role_group_configs
let rg = cluster
.role_group_configs(role)
.get(role_group_name)
.with_context(|| MissingRoleGroupSnafu {
role: role.to_string(),
Expand Down
6 changes: 2 additions & 4 deletions rust/operator-binary/src/controller/build/resource/pdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ pub fn build_pdb(
/// contribute nothing, as their size is not known at reconcile time.
fn worker_count(cluster: &ValidatedCluster) -> u16 {
cluster
.role_group_configs
.get(&TrinoRole::Worker)
.into_iter()
.flat_map(|groups| groups.values())
.worker_role_group_configs
.values()
.filter_map(|rg| rg.replicas)
.sum()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,7 @@ mod tests {
/// Builds the coordinator `default` role-group StatefulSet for the given cluster.
fn build_coordinator_statefulset(cluster: &ValidatedCluster) -> Result<StatefulSet> {
let role_group_name = RoleGroupName::from_str("default").expect("valid role group name");
let role_group_config =
&cluster.role_group_configs[&TrinoRole::Coordinator][&role_group_name];
let role_group_config = &cluster.coordinator_role_group_configs[&role_group_name];

build_rolegroup_statefulset(
cluster,
Expand Down Expand Up @@ -851,7 +850,7 @@ mod tests {
let cluster = validated_cluster();
let role_group_name = RoleGroupName::from_str("default").expect("valid role group name");
let mut role_group_config =
cluster.role_group_configs[&TrinoRole::Coordinator][&role_group_name].clone();
cluster.coordinator_role_group_configs[&role_group_name].clone();
role_group_config.env_overrides = EnvVarSet::new().with_value(
&EnvVarName::from_str("CONTAINERDEBUG_LOG_DIRECTORY").expect("valid env var name"),
"/custom/log/dir",
Expand Down
Loading
Loading