Skip to content

Commit ab97223

Browse files
committed
versioning for the TrinoCluster and referenced specs
1 parent fef4dea commit ab97223

File tree

10 files changed

+303
-282
lines changed

10 files changed

+303
-282
lines changed

rust/operator-binary/src/authorization/opa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use stackable_operator::{
55
commons::opa::{OpaApiVersion, OpaConfig},
66
};
77

8-
use crate::crd::TrinoCluster;
8+
use crate::crd::v1alpha1::TrinoCluster;
99

1010
pub struct TrinoOpaConfig {
1111
/// URI for OPA policies, e.g.

rust/operator-binary/src/command.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ use crate::{
1111
catalog::config::CatalogConfig,
1212
controller::{STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR},
1313
crd::{
14-
Container, TrinoCluster, TrinoConfig, TrinoRole, CONFIG_DIR_NAME, DATA_DIR_NAME,
15-
LOG_PROPERTIES, RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR, STACKABLE_INTERNAL_TLS_DIR,
14+
v1alpha1, Container, TrinoRole, CONFIG_DIR_NAME, DATA_DIR_NAME, LOG_PROPERTIES,
15+
RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR, STACKABLE_INTERNAL_TLS_DIR,
1616
STACKABLE_MOUNT_INTERNAL_TLS_DIR, STACKABLE_MOUNT_SERVER_TLS_DIR, STACKABLE_SERVER_TLS_DIR,
1717
STACKABLE_TLS_STORE_PASSWORD, SYSTEM_TRUST_STORE, SYSTEM_TRUST_STORE_PASSWORD,
1818
},
1919
};
2020

2121
pub fn container_prepare_args(
22-
trino: &TrinoCluster,
22+
trino: &v1alpha1::TrinoCluster,
2323
catalogs: &[CatalogConfig],
24-
merged_config: &TrinoConfig,
24+
merged_config: &v1alpha1::TrinoConfig,
2525
) -> Vec<String> {
2626
let mut args = vec![];
2727

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use stackable_operator::{
77
};
88

99
use crate::crd::{
10-
TrinoConfig, TrinoConfigFragment, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES, METRICS_PORT,
11-
RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR, STACKABLE_TLS_STORE_PASSWORD,
10+
v1alpha1, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES, METRICS_PORT, RW_CONFIG_DIR_NAME,
11+
STACKABLE_CLIENT_TLS_DIR, STACKABLE_TLS_STORE_PASSWORD,
1212
};
1313

1414
#[derive(Snafu, Debug)]
@@ -39,8 +39,8 @@ pub enum Error {
3939
// in the future depending on the role and version.
4040
pub fn jvm_config(
4141
product_version: &str,
42-
merged_config: &TrinoConfig,
43-
role: &Role<TrinoConfigFragment, GenericRoleConfig, JavaCommonConfig>,
42+
merged_config: &v1alpha1::TrinoConfig,
43+
role: &Role<v1alpha1::TrinoConfigFragment, GenericRoleConfig, JavaCommonConfig>,
4444
role_group: &str,
4545
) -> Result<String, Error> {
4646
let memory_unit = BinaryMultiple::Mebi;
@@ -153,7 +153,7 @@ mod tests {
153153
use indoc::indoc;
154154

155155
use super::*;
156-
use crate::crd::{TrinoCluster, TrinoRole};
156+
use crate::crd::{v1alpha1, TrinoRole};
157157

158158
#[test]
159159
fn test_jvm_config_defaults() {
@@ -262,7 +262,8 @@ mod tests {
262262
}
263263

264264
fn construct_jvm_config(trino_cluster: &str) -> String {
265-
let trino: TrinoCluster = serde_yaml::from_str(trino_cluster).expect("illegal test input");
265+
let trino: v1alpha1::TrinoCluster =
266+
serde_yaml::from_str(trino_cluster).expect("illegal test input");
266267

267268
let role = TrinoRole::Coordinator;
268269
let rolegroup_ref = role.rolegroup_ref(&trino, "default");

rust/operator-binary/src/controller.rs

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ use crate::{
8080
command, config,
8181
crd::{
8282
authentication::resolve_authentication_classes,
83-
catalog::v1alpha1,
83+
catalog,
8484
discovery::{TrinoDiscovery, TrinoDiscoveryProtocol, TrinoPodRef},
85-
Container, TrinoCluster, TrinoClusterStatus, TrinoConfig, TrinoConfigFragment, TrinoRole,
86-
ACCESS_CONTROL_PROPERTIES, APP_NAME, CONFIG_DIR_NAME, CONFIG_PROPERTIES, DATA_DIR_NAME,
87-
DISCOVERY_URI, ENV_INTERNAL_SECRET, HTTPS_PORT, HTTPS_PORT_NAME, HTTP_PORT, HTTP_PORT_NAME,
88-
JVM_CONFIG, JVM_SECURITY_PROPERTIES, LOG_COMPRESSION, LOG_FORMAT, LOG_MAX_SIZE,
89-
LOG_MAX_TOTAL_SIZE, LOG_PATH, LOG_PROPERTIES, METRICS_PORT, METRICS_PORT_NAME,
90-
NODE_PROPERTIES, RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR, STACKABLE_INTERNAL_TLS_DIR,
91-
STACKABLE_MOUNT_INTERNAL_TLS_DIR, STACKABLE_MOUNT_SERVER_TLS_DIR, STACKABLE_SERVER_TLS_DIR,
85+
v1alpha1, Container, TrinoRole, ACCESS_CONTROL_PROPERTIES, APP_NAME, CONFIG_DIR_NAME,
86+
CONFIG_PROPERTIES, DATA_DIR_NAME, DISCOVERY_URI, ENV_INTERNAL_SECRET, HTTPS_PORT,
87+
HTTPS_PORT_NAME, HTTP_PORT, HTTP_PORT_NAME, JVM_CONFIG, JVM_SECURITY_PROPERTIES,
88+
LOG_COMPRESSION, LOG_FORMAT, LOG_MAX_SIZE, LOG_MAX_TOTAL_SIZE, LOG_PATH, LOG_PROPERTIES,
89+
METRICS_PORT, METRICS_PORT_NAME, NODE_PROPERTIES, RW_CONFIG_DIR_NAME,
90+
STACKABLE_CLIENT_TLS_DIR, STACKABLE_INTERNAL_TLS_DIR, STACKABLE_MOUNT_INTERNAL_TLS_DIR,
91+
STACKABLE_MOUNT_SERVER_TLS_DIR, STACKABLE_SERVER_TLS_DIR,
9292
},
9393
operations::{
9494
add_graceful_shutdown_config, graceful_shutdown_config_properties, pdb::add_pdbs,
@@ -152,25 +152,25 @@ pub enum Error {
152152
#[snafu(display("failed to apply Service for {}", rolegroup))]
153153
ApplyRoleGroupService {
154154
source: stackable_operator::cluster_resources::Error,
155-
rolegroup: RoleGroupRef<TrinoCluster>,
155+
rolegroup: RoleGroupRef<v1alpha1::TrinoCluster>,
156156
},
157157

158158
#[snafu(display("failed to build ConfigMap for {}", rolegroup))]
159159
BuildRoleGroupConfig {
160160
source: stackable_operator::builder::configmap::Error,
161-
rolegroup: RoleGroupRef<TrinoCluster>,
161+
rolegroup: RoleGroupRef<v1alpha1::TrinoCluster>,
162162
},
163163

164164
#[snafu(display("failed to apply ConfigMap for {}", rolegroup))]
165165
ApplyRoleGroupConfig {
166166
source: stackable_operator::cluster_resources::Error,
167-
rolegroup: RoleGroupRef<TrinoCluster>,
167+
rolegroup: RoleGroupRef<v1alpha1::TrinoCluster>,
168168
},
169169

170170
#[snafu(display("failed to apply StatefulSet for {}", rolegroup))]
171171
ApplyRoleGroupStatefulSet {
172172
source: stackable_operator::cluster_resources::Error,
173-
rolegroup: RoleGroupRef<TrinoCluster>,
173+
rolegroup: RoleGroupRef<v1alpha1::TrinoCluster>,
174174
},
175175

176176
#[snafu(display("failed to apply internal secret"))]
@@ -218,7 +218,7 @@ pub enum Error {
218218
#[snafu(display("failed to parse {catalog}"))]
219219
ParseCatalog {
220220
source: FromTrinoCatalogError,
221-
catalog: ObjectRef<v1alpha1::TrinoCatalog>,
221+
catalog: ObjectRef<catalog::v1alpha1::TrinoCatalog>,
222222
},
223223

224224
#[snafu(display("illegal container name: [{container_name}]"))]
@@ -360,7 +360,7 @@ impl ReconcilerError for Error {
360360
}
361361

362362
pub async fn reconcile_trino(
363-
trino: Arc<DeserializeGuard<TrinoCluster>>,
363+
trino: Arc<DeserializeGuard<v1alpha1::TrinoCluster>>,
364364
ctx: Arc<Ctx>,
365365
) -> Result<Action> {
366366
tracing::info!("Starting reconcile");
@@ -389,7 +389,7 @@ pub async fn reconcile_trino(
389389
.context(InvalidAuthenticationConfigSnafu)?;
390390

391391
let catalog_definitions = client
392-
.list_with_label_selector::<v1alpha1::TrinoCatalog>(
392+
.list_with_label_selector::<catalog::v1alpha1::TrinoCatalog>(
393393
trino
394394
.metadata
395395
.namespace
@@ -475,7 +475,7 @@ pub async fn reconcile_trino(
475475

476476
for (trino_role_str, role_config) in validated_config {
477477
let trino_role = TrinoRole::from_str(&trino_role_str).context(FailedToParseRoleSnafu)?;
478-
let role: &Role<TrinoConfigFragment, GenericRoleConfig, JavaCommonConfig> =
478+
let role: &Role<v1alpha1::TrinoConfigFragment, GenericRoleConfig, JavaCommonConfig> =
479479
trino.role(&trino_role).context(ReadRoleSnafu)?;
480480
for (role_group, config) in role_config {
481481
let rolegroup = trino_role.rolegroup_ref(trino, &role_group);
@@ -561,7 +561,7 @@ pub async fn reconcile_trino(
561561
let cluster_operation_cond_builder =
562562
ClusterOperationsConditionBuilder::new(&trino.spec.cluster_operation);
563563

564-
let status = TrinoClusterStatus {
564+
let status = v1alpha1::TrinoClusterStatus {
565565
conditions: compute_conditions(
566566
trino,
567567
&[&sts_cond_builder, &cluster_operation_cond_builder],
@@ -583,7 +583,7 @@ pub async fn reconcile_trino(
583583
/// The coordinator-role service is the primary endpoint that should be used by clients that do not
584584
/// perform internal load balancing, including targets outside of the cluster.
585585
pub fn build_coordinator_role_service(
586-
trino: &TrinoCluster,
586+
trino: &v1alpha1::TrinoCluster,
587587
resolved_product_image: &ResolvedProductImage,
588588
) -> Result<Service> {
589589
let role = TrinoRole::Coordinator;
@@ -622,13 +622,13 @@ pub fn build_coordinator_role_service(
622622
/// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator
623623
#[allow(clippy::too_many_arguments)]
624624
fn build_rolegroup_config_map(
625-
trino: &TrinoCluster,
625+
trino: &v1alpha1::TrinoCluster,
626626
resolved_product_image: &ResolvedProductImage,
627-
role: &Role<TrinoConfigFragment, GenericRoleConfig, JavaCommonConfig>,
627+
role: &Role<v1alpha1::TrinoConfigFragment, GenericRoleConfig, JavaCommonConfig>,
628628
trino_role: &TrinoRole,
629-
rolegroup_ref: &RoleGroupRef<TrinoCluster>,
629+
rolegroup_ref: &RoleGroupRef<v1alpha1::TrinoCluster>,
630630
config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
631-
merged_config: &TrinoConfig,
631+
merged_config: &v1alpha1::TrinoConfig,
632632
trino_authentication_config: &TrinoAuthenticationConfig,
633633
trino_opa_config: &Option<TrinoOpaConfig>,
634634
vector_aggregator_address: Option<&str>,
@@ -830,9 +830,9 @@ fn build_rolegroup_config_map(
830830
/// The rolegroup catalog [`ConfigMap`] configures the rolegroup catalog based on the configuration
831831
/// given by the administrator
832832
fn build_rolegroup_catalog_config_map(
833-
trino: &TrinoCluster,
833+
trino: &v1alpha1::TrinoCluster,
834834
resolved_product_image: &ResolvedProductImage,
835-
rolegroup_ref: &RoleGroupRef<TrinoCluster>,
835+
rolegroup_ref: &RoleGroupRef<v1alpha1::TrinoCluster>,
836836
catalogs: &[CatalogConfig],
837837
) -> Result<ConfigMap> {
838838
ConfigMapBuilder::new()
@@ -886,12 +886,12 @@ fn build_rolegroup_catalog_config_map(
886886
/// corresponding [`Service`] (from [`build_rolegroup_service`]).
887887
#[allow(clippy::too_many_arguments)]
888888
fn build_rolegroup_statefulset(
889-
trino: &TrinoCluster,
889+
trino: &v1alpha1::TrinoCluster,
890890
trino_role: &TrinoRole,
891891
resolved_product_image: &ResolvedProductImage,
892-
rolegroup_ref: &RoleGroupRef<TrinoCluster>,
892+
rolegroup_ref: &RoleGroupRef<v1alpha1::TrinoCluster>,
893893
config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
894-
merged_config: &TrinoConfig,
894+
merged_config: &v1alpha1::TrinoConfig,
895895
trino_authentication_config: &TrinoAuthenticationConfig,
896896
catalogs: &[CatalogConfig],
897897
sa_name: &str,
@@ -1226,9 +1226,9 @@ fn build_rolegroup_statefulset(
12261226
///
12271227
/// This is mostly useful for internal communication between peers, or for clients that perform client-side load balancing.
12281228
fn build_rolegroup_service(
1229-
trino: &TrinoCluster,
1229+
trino: &v1alpha1::TrinoCluster,
12301230
resolved_product_image: &ResolvedProductImage,
1231-
rolegroup_ref: &RoleGroupRef<TrinoCluster>,
1231+
rolegroup_ref: &RoleGroupRef<v1alpha1::TrinoCluster>,
12321232
) -> Result<Service> {
12331233
Ok(Service {
12341234
metadata: ObjectMetaBuilder::new()
@@ -1268,7 +1268,7 @@ fn build_rolegroup_service(
12681268
}
12691269

12701270
pub fn error_policy(
1271-
_obj: Arc<DeserializeGuard<TrinoCluster>>,
1271+
_obj: Arc<DeserializeGuard<v1alpha1::TrinoCluster>>,
12721272
error: &Error,
12731273
_ctx: Arc<Ctx>,
12741274
) -> Action {
@@ -1306,7 +1306,7 @@ fn env_var_from_secret(secret_name: &str, secret_key: Option<&str>, env_var: &st
13061306
/// * `product_config` - The product config to validate and complement the user config.
13071307
///
13081308
fn validated_product_config(
1309-
trino: &TrinoCluster,
1309+
trino: &v1alpha1::TrinoCluster,
13101310
version: &str,
13111311
product_config: &ProductConfigManager,
13121312
) -> Result<ValidatedRoleConfigByPropertyKind, Error> {
@@ -1357,11 +1357,11 @@ fn validated_product_config(
13571357
}
13581358

13591359
fn build_recommended_labels<'a>(
1360-
owner: &'a TrinoCluster,
1360+
owner: &'a v1alpha1::TrinoCluster,
13611361
app_version: &'a str,
13621362
role: &'a str,
13631363
role_group: &'a str,
1364-
) -> ObjectLabels<'a, TrinoCluster> {
1364+
) -> ObjectLabels<'a, v1alpha1::TrinoCluster> {
13651365
ObjectLabels {
13661366
owner,
13671367
app_name: APP_NAME,
@@ -1373,7 +1373,10 @@ fn build_recommended_labels<'a>(
13731373
}
13741374
}
13751375

1376-
async fn create_shared_internal_secret(trino: &TrinoCluster, client: &Client) -> Result<()> {
1376+
async fn create_shared_internal_secret(
1377+
trino: &v1alpha1::TrinoCluster,
1378+
client: &Client,
1379+
) -> Result<()> {
13771380
let secret = build_shared_internal_secret(trino)?;
13781381
if client
13791382
.get_opt::<Secret>(
@@ -1396,7 +1399,7 @@ async fn create_shared_internal_secret(trino: &TrinoCluster, client: &Client) ->
13961399
Ok(())
13971400
}
13981401

1399-
fn build_shared_internal_secret(trino: &TrinoCluster) -> Result<Secret> {
1402+
fn build_shared_internal_secret(trino: &v1alpha1::TrinoCluster) -> Result<Secret> {
14001403
let mut internal_secret = BTreeMap::new();
14011404
internal_secret.insert(ENV_INTERNAL_SECRET.to_string(), get_random_base64());
14021405

@@ -1413,7 +1416,7 @@ fn build_shared_internal_secret(trino: &TrinoCluster) -> Result<Secret> {
14131416
})
14141417
}
14151418

1416-
fn build_shared_internal_secret_name(trino: &TrinoCluster) -> String {
1419+
fn build_shared_internal_secret_name(trino: &v1alpha1::TrinoCluster) -> String {
14171420
format!("{}-internal-secret", trino.name_any())
14181421
}
14191422

@@ -1423,7 +1426,7 @@ fn get_random_base64() -> String {
14231426
openssl::base64::encode_block(&buf)
14241427
}
14251428

1426-
fn service_ports(trino: &TrinoCluster) -> Vec<ServicePort> {
1429+
fn service_ports(trino: &v1alpha1::TrinoCluster) -> Vec<ServicePort> {
14271430
let mut ports = vec![ServicePort {
14281431
name: Some(METRICS_PORT_NAME.to_string()),
14291432
port: METRICS_PORT.into(),
@@ -1452,7 +1455,7 @@ fn service_ports(trino: &TrinoCluster) -> Vec<ServicePort> {
14521455
ports
14531456
}
14541457

1455-
fn container_ports(trino: &TrinoCluster) -> Vec<ContainerPort> {
1458+
fn container_ports(trino: &v1alpha1::TrinoCluster) -> Vec<ContainerPort> {
14561459
let mut ports = vec![ContainerPort {
14571460
name: Some(METRICS_PORT_NAME.to_string()),
14581461
container_port: METRICS_PORT.into(),
@@ -1481,7 +1484,7 @@ fn container_ports(trino: &TrinoCluster) -> Vec<ContainerPort> {
14811484
ports
14821485
}
14831486

1484-
fn readiness_probe(trino: &TrinoCluster) -> Probe {
1487+
fn readiness_probe(trino: &v1alpha1::TrinoCluster) -> Probe {
14851488
let port_name = if trino.expose_https_port() {
14861489
HTTPS_PORT_NAME
14871490
} else {
@@ -1500,7 +1503,7 @@ fn readiness_probe(trino: &TrinoCluster) -> Probe {
15001503
}
15011504
}
15021505

1503-
fn liveness_probe(trino: &TrinoCluster) -> Probe {
1506+
fn liveness_probe(trino: &v1alpha1::TrinoCluster) -> Probe {
15041507
let port_name = if trino.expose_https_port() {
15051508
HTTPS_PORT_NAME
15061509
} else {
@@ -1537,7 +1540,7 @@ fn create_tls_volume(
15371540
}
15381541

15391542
fn tls_volume_mounts(
1540-
trino: &TrinoCluster,
1543+
trino: &v1alpha1::TrinoCluster,
15411544
pod_builder: &mut PodBuilder,
15421545
cb_prepare: &mut ContainerBuilder,
15431546
cb_trino: &mut ContainerBuilder,
@@ -1686,7 +1689,8 @@ mod tests {
16861689
}
16871690

16881691
fn build_config_map(trino_yaml: &str) -> ConfigMap {
1689-
let mut trino: TrinoCluster = serde_yaml::from_str(trino_yaml).expect("illegal test input");
1692+
let mut trino: v1alpha1::TrinoCluster =
1693+
serde_yaml::from_str(trino_yaml).expect("illegal test input");
16901694
trino.metadata.namespace = Some("default".to_owned());
16911695
trino.metadata.uid = Some("42".to_owned());
16921696
let cluster_info = KubernetesClusterInfo {
@@ -1803,7 +1807,7 @@ mod tests {
18031807
replicas: 1
18041808
"#;
18051809
let deserializer = serde_yaml::Deserializer::from_str(trino_yaml);
1806-
let trino: TrinoCluster =
1810+
let trino: v1alpha1::TrinoCluster =
18071811
serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap();
18081812

18091813
let validated_config = validated_product_config(

0 commit comments

Comments
 (0)