Skip to content

Commit 4a66071

Browse files
committed
refactor: move command.rs to build, use ConfigFileNames, remove v2 / upstream references
1 parent 1739d44 commit 4a66071

15 files changed

Lines changed: 40 additions & 48 deletions

File tree

rust/operator-binary/src/authentication/oidc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use stackable_operator::{
88

99
use crate::{
1010
authentication::TrinoAuthenticationConfig,
11-
command,
11+
controller::build::command,
1212
crd::{STACKABLE_CLIENT_TLS_DIR, TrinoRole},
1313
};
1414

rust/operator-binary/src/config/client_protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Consolidate Trino S3 properties in a single reusable struct.
1+
//! Resolves the Trino client (spooling) protocol configuration.
22
33
use std::collections::BTreeMap;
44

rust/operator-binary/src/config/s3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use stackable_operator::{
88
k8s_openapi::api::core::v1::{Volume, VolumeMount},
99
};
1010

11-
use crate::{command, crd::STACKABLE_CLIENT_TLS_DIR};
11+
use crate::{controller::build::command, crd::STACKABLE_CLIENT_TLS_DIR};
1212

1313
#[derive(Snafu, Debug)]
1414
pub enum Error {

rust/operator-binary/src/controller/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Builders that turn a `ValidatedCluster` into Kubernetes resource contents.
22
3+
pub mod command;
34
pub mod graceful_shutdown;
45
pub mod ports;
56
pub mod properties;

rust/operator-binary/src/command.rs renamed to rust/operator-binary/src/controller/build/command.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
authentication::TrinoAuthenticationConfig,
1111
catalog::config::CatalogConfig,
1212
config::{client_protocol, fault_tolerant_execution},
13-
controller::{ValidatedCluster, ValidatedTrinoConfig},
13+
controller::{ValidatedCluster, ValidatedTrinoConfig, build::properties::ConfigFileName},
1414
crd::{
1515
CONFIG_DIR_NAME, Container, RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR,
1616
STACKABLE_INTERNAL_TLS_DIR, STACKABLE_MOUNT_INTERNAL_TLS_DIR,
@@ -20,12 +20,6 @@ use crate::{
2020
trino_controller::{STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR},
2121
};
2222

23-
// TODO: replace with build::properties::ConfigFileName once command.rs moves under build/
24-
// (with the StatefulSet builder migration).
25-
const LOG_PROPERTIES: &str = "log.properties";
26-
const EXCHANGE_MANAGER_PROPERTIES: &str = "exchange-manager.properties";
27-
const SPOOLING_MANAGER_PROPERTIES: &str = "spooling-manager.properties";
28-
2923
pub fn container_prepare_args(
3024
cluster: &ValidatedCluster,
3125
catalogs: &[CatalogConfig],
@@ -37,13 +31,14 @@ pub fn container_prepare_args(
3731

3832
// Copy custom logging provided `log.properties` to rw config
3933
if let ValidatedContainerLogConfigChoice::Custom(_) = merged_config.logging.trino_container {
34+
let log_properties = ConfigFileName::Log;
4035
// copy config files to a writeable empty folder
4136
args.push(format!(
42-
"echo copying {STACKABLE_LOG_CONFIG_DIR}/{LOG_PROPERTIES} {rw_conf}/{LOG_PROPERTIES}",
37+
"echo copying {STACKABLE_LOG_CONFIG_DIR}/{log_properties} {rw_conf}/{log_properties}",
4338
rw_conf = RW_CONFIG_DIR_NAME
4439
));
4540
args.push(format!(
46-
"cp -RL {STACKABLE_LOG_CONFIG_DIR}/{LOG_PROPERTIES} {rw_conf}/{LOG_PROPERTIES}",
41+
"cp -RL {STACKABLE_LOG_CONFIG_DIR}/{log_properties} {rw_conf}/{log_properties}",
4742
rw_conf = RW_CONFIG_DIR_NAME
4843
));
4944
}
@@ -118,13 +113,19 @@ pub fn container_trino_args(
118113
// Resolve credentials for fault tolerant execution exchange manager if needed
119114
args.push(format!(
120115
"test -f {rw_exchange_manager_config_file} && config-utils template {rw_exchange_manager_config_file}",
121-
rw_exchange_manager_config_file = format!("{RW_CONFIG_DIR_NAME}/{EXCHANGE_MANAGER_PROPERTIES}")
116+
rw_exchange_manager_config_file = format!(
117+
"{RW_CONFIG_DIR_NAME}/{exchange_manager}",
118+
exchange_manager = ConfigFileName::ExchangeManager
119+
)
122120
));
123121

124122
// Resolve credentials for spooling manager if needed
125123
args.push(format!(
126124
"test -f {rw_spooling_config_file} && config-utils template {rw_spooling_config_file}",
127-
rw_spooling_config_file = format!("{RW_CONFIG_DIR_NAME}/{SPOOLING_MANAGER_PROPERTIES}")
125+
rw_spooling_config_file = format!(
126+
"{RW_CONFIG_DIR_NAME}/{spooling_manager}",
127+
spooling_manager = ConfigFileName::SpoolingManager
128+
)
128129
));
129130

130131
args.push("set -x".to_string());

rust/operator-binary/src/controller/build/properties/config_properties.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const LOG_COMPRESSION: &str = "log.compression";
5151
const LOG_MAX_SIZE: &str = "log.max-size";
5252
const LOG_MAX_TOTAL_SIZE: &str = "log.max-total-size";
5353

54-
// Defaults migrated from deploy/config-spec/properties.yaml.
54+
// Default values for `config.properties`.
5555
const DEFAULT_QUERY_MAX_MEMORY: &str = "50GB";
5656
const DEFAULT_NODE_SCHEDULER_INCLUDE_COORDINATOR: &str = "false";
5757

@@ -134,8 +134,7 @@ pub fn build(
134134
format!("${{ENV:{ENV_INTERNAL_SECRET}}}"),
135135
);
136136

137-
// TLS gating — mirrors the existing compute_files logic, including the
138-
// authentication-requires-TLS check.
137+
// TLS gating, including the authentication-requires-TLS check.
139138
let server_tls_enabled = cluster.server_tls_enabled();
140139
let internal_tls_enabled = cluster.internal_tls_enabled();
141140
if cluster.cluster_config.authentication_enabled() && !server_tls_enabled {

rust/operator-binary/src/controller/build/properties/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Per-file builders for Trino `.properties` files.
22
//!
33
//! Each `<file>.rs` module produces the rendered key/value pairs for one
4-
//! Trino config file. The shared
5-
//! [`stackable_operator::v2::config_file_writer`] serializes the map to the
4+
//! Trino config file. The shared config-file writer serializes the map to the
65
//! Java-properties on-wire format.
76
87
pub mod access_control_properties;
@@ -101,8 +100,7 @@ mod tests {
101100
}
102101

103102
/// The escape behaviours pinned by the kuttl smoke snapshot
104-
/// (`tests/templates/kuttl/smoke/14-assert.yaml.j2`); previously asserted
105-
/// against the hand-rolled writer, now against the shared one.
103+
/// (`tests/templates/kuttl/smoke/14-assert.yaml.j2`).
106104
#[test]
107105
fn kuttl_pinned_escapes_are_stable() {
108106
assert_eq!(

rust/operator-binary/src/controller/build/properties/product_logging/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// The Vector agent configuration (`vector.yaml`).
44
///
55
/// It is templated with environment variables (`${LOG_DIR}`, `${NAMESPACE}`, …) that the
6-
/// `v2` Vector container injects at runtime, so the same file content is used for every
6+
/// Vector container injects at runtime, so the same file content is used for every
77
/// rolegroup.
88
const VECTOR_CONFIG: &str = include_str!("vector.yaml");
99

rust/operator-binary/src/controller/build/resource/config_map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ pub fn build_rolegroup_config_map(
8080

8181
let mut data: BTreeMap<String, String> = BTreeMap::new();
8282

83-
// Auth files (e.g. password-authenticator file contents) — inserted FIRST
84-
// to match the legacy precedence.
83+
// Auth files (e.g. password-authenticator file contents).
8584
for (file_name, props) in cluster.cluster_config.authentication.config_files(role) {
8685
let rendered =
8786
to_java_properties_string(props.iter()).with_context(|_| WritePropertiesSnafu {

rust/operator-binary/src/controller/build/resource/statefulset.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ use stackable_operator::{
3939

4040
use crate::{
4141
authorization::opa::OPA_TLS_VOLUME_NAME,
42-
command,
4342
controller::{
4443
TrinoRoleGroupConfig, ValidatedCluster, build,
45-
build::resource::listener::{
46-
LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, build_group_listener_pvc,
47-
group_listener_name, secret_volume_listener_scope,
44+
build::{
45+
command,
46+
resource::listener::{
47+
LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, build_group_listener_pvc,
48+
group_listener_name, secret_volume_listener_scope,
49+
},
4850
},
4951
},
5052
crd::{
@@ -426,9 +428,8 @@ pub fn build_rolegroup_statefulset(
426428
.security_context(PodSecurityContextBuilder::new().fs_group(1000).build());
427429

428430
let mut pod_template = pod_builder.build_template();
429-
// `pod_overrides` already carries the merged role + role-group overrides (see
430-
// `with_validated_config`), so a single merge here is equivalent to the previous
431-
// role-then-role-group sequence.
431+
// `pod_overrides` already carries the merged role + role-group overrides, so a single merge
432+
// here applies both.
432433
pod_template.merge_from(role_group_config.pod_overrides.clone());
433434

434435
let annotations = restarter_ignore_secret_annotations(

0 commit comments

Comments
 (0)