Skip to content

Commit 3ee743b

Browse files
committed
fix: remove config and move to build mod
1 parent f63f975 commit 3ee743b

11 files changed

Lines changed: 30 additions & 34 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/operator-binary/src/controller.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,20 @@ use strum::EnumDiscriminants;
7777

7878
use crate::{
7979
OPERATOR_NAME,
80-
command::build_container_command_args,
81-
config::{
80+
controller::build::{
81+
command::build_container_command_args,
82+
discovery,
8283
jvm::{construct_hadoop_heapsize_env, construct_non_heap_jvm_args},
84+
kerberos::{self, add_kerberos_pod_config, kerberos_container_start_commands},
8385
opa::{HiveOpaConfig, OPA_TLS_VOLUME_NAME},
8486
},
85-
controller::build::discovery,
8687
crd::{
8788
APP_NAME, Container, HIVE_PORT, HIVE_PORT_NAME, HiveClusterStatus, HiveRole, METRICS_PORT,
8889
METRICS_PORT_NAME, MetaStoreConfig, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME,
8990
STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_CONFIG_MOUNT_DIR_NAME,
9091
STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_DIR,
9192
STACKABLE_LOG_DIR_NAME, v1alpha1,
9293
},
93-
kerberos::{self, add_kerberos_pod_config, kerberos_container_start_commands},
9494
listener::{LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, build_role_listener},
9595
operations::{graceful_shutdown::add_graceful_shutdown_config, pdb::add_pdbs},
9696
service::{build_rolegroup_headless_service, build_rolegroup_metrics_service},
@@ -250,7 +250,9 @@ pub enum Error {
250250
},
251251

252252
#[snafu(display("failed to construct JVM arguments"))]
253-
ConstructJvmArguments { source: crate::config::jvm::Error },
253+
ConstructJvmArguments {
254+
source: crate::controller::build::jvm::Error,
255+
},
254256

255257
#[snafu(display("failed to apply group listener for {role}"))]
256258
ApplyGroupListener {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
use stackable_operator::crd::s3;
22

3-
use crate::{
4-
config::opa::HiveOpaConfig,
5-
crd::{
6-
HIVE_METASTORE_LOG4J2_PROPERTIES, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_MOUNT_DIR,
7-
STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_TRUST_STORE, STACKABLE_TRUST_STORE_PASSWORD,
8-
v1alpha1,
9-
},
3+
use super::{opa::HiveOpaConfig, properties::ConfigFileName};
4+
use crate::crd::{
5+
STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR,
6+
STACKABLE_TRUST_STORE, STACKABLE_TRUST_STORE_PASSWORD, v1alpha1,
107
};
118

129
pub fn build_container_command_args(
@@ -15,16 +12,17 @@ pub fn build_container_command_args(
1512
s3_connection_spec: Option<&s3::v1alpha1::ConnectionSpec>,
1613
hive_opa_config: Option<&HiveOpaConfig>,
1714
) -> Vec<String> {
15+
let log4j2_properties = ConfigFileName::Log4j2;
1816
let mut args = vec![
1917
// copy config files to a writeable empty folder in order to set s3 access and secret keys
2018
format!("echo copying {STACKABLE_CONFIG_MOUNT_DIR} to {STACKABLE_CONFIG_DIR}"),
2119
format!("cp -RL {STACKABLE_CONFIG_MOUNT_DIR}/* {STACKABLE_CONFIG_DIR}"),
2220
// Copy log4j2 properties
2321
format!(
24-
"echo copying {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES} to {STACKABLE_CONFIG_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES}"
22+
"echo copying {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{log4j2_properties} to {STACKABLE_CONFIG_DIR}/{log4j2_properties}"
2523
),
2624
format!(
27-
"cp -RL {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES} {STACKABLE_CONFIG_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES}"
25+
"cp -RL {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{log4j2_properties} {STACKABLE_CONFIG_DIR}/{log4j2_properties}"
2826
),
2927
// Template config files
3028
format!(

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use stackable_operator::{
44
role_utils::{self, JvmArgumentOverrides},
55
};
66

7+
use super::properties::ConfigFileName;
78
use crate::crd::{
8-
HiveRoleType, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT, MetaStoreConfig,
9-
STACKABLE_CONFIG_DIR, STACKABLE_TRUST_STORE, STACKABLE_TRUST_STORE_PASSWORD,
10-
v1alpha1::HiveCluster,
9+
HiveRoleType, METRICS_PORT, MetaStoreConfig, STACKABLE_CONFIG_DIR, STACKABLE_TRUST_STORE,
10+
STACKABLE_TRUST_STORE_PASSWORD, v1alpha1::HiveCluster,
1111
};
1212

1313
const JAVA_HEAP_FACTOR: f32 = 0.8;
@@ -32,8 +32,9 @@ fn construct_jvm_args(
3232
role: &HiveRoleType,
3333
role_group: &str,
3434
) -> Result<Vec<String>, Error> {
35+
let security_properties = ConfigFileName::Security;
3536
let mut jvm_args = vec![
36-
format!("-Djava.security.properties={STACKABLE_CONFIG_DIR}/{JVM_SECURITY_PROPERTIES_FILE}"),
37+
format!("-Djava.security.properties={STACKABLE_CONFIG_DIR}/{security_properties}"),
3738
format!(
3839
"-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar={METRICS_PORT}:/stackable/jmx/jmx_hive_config.yaml"
3940
),

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use stackable_operator::{
1919
utils::cluster_info::KubernetesClusterInfo,
2020
};
2121

22-
use crate::crd::{HIVE_SITE_XML, HiveRole, STACKABLE_CONFIG_DIR, v1alpha1};
22+
use super::properties::ConfigFileName;
23+
use crate::crd::{HiveRole, STACKABLE_CONFIG_DIR, v1alpha1};
2324

2425
#[derive(Snafu, Debug)]
2526
#[allow(clippy::enum_variant_names)] // all variants have the same prefix: `Add`
@@ -110,9 +111,10 @@ pub fn kerberos_container_start_commands(hive: &v1alpha1::HiveCluster) -> String
110111
return String::new();
111112
}
112113

114+
let hive_site_xml = ConfigFileName::HiveSite;
113115
let mut args = vec![formatdoc! {"
114116
export KERBEROS_REALM=$(grep -oP 'default_realm = \\K.*' /stackable/kerberos/krb5.conf)
115-
sed -i -e 's/${{env.KERBEROS_REALM}}/'\"$KERBEROS_REALM/g\" {STACKABLE_CONFIG_DIR}/{HIVE_SITE_XML}",
117+
sed -i -e 's/${{env.KERBEROS_REALM}}/'\"$KERBEROS_REALM/g\" {STACKABLE_CONFIG_DIR}/{hive_site_xml}",
116118
}];
117119

118120
if hive.spec.cluster_config.hdfs.is_some() {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
//! Builders that turn a `ValidatedCluster` into Kubernetes resources.
22
3+
pub mod command;
34
pub mod config_map;
45
pub mod discovery;
6+
pub mod jvm;
7+
pub mod kerberos;
8+
pub mod opa;
59
pub mod properties;
File renamed without changes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use snafu::{ResultExt, Snafu};
22
use stackable_operator::{crd::s3, kube::ResourceExt};
33

4-
use crate::{config::opa::HiveOpaConfig, crd::v1alpha1};
4+
use crate::{controller::build::opa::HiveOpaConfig, crd::v1alpha1};
55

66
#[derive(Snafu, Debug)]
77
pub enum Error {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ use stackable_operator::{
1515
use crate::{
1616
controller::{
1717
CONTAINER_IMAGE_BASE_NAME, HiveRoleGroupConfig, RoleGroupName, ValidatedCluster,
18-
ValidatedClusterConfig, ValidatedRoleConfig, dereference::DereferencedObjects,
18+
ValidatedClusterConfig, ValidatedRoleConfig, build::kerberos::kerberos_config_properties,
19+
dereference::DereferencedObjects,
1920
},
2021
crd::{
2122
HiveRole, MetaStoreConfig,
2223
databases::{MetadataDatabaseConnection, derby_driver_class},
2324
v1alpha1::{self, HiveMetastoreRoleConfig},
2425
},
2526
framework::role_utils::with_validated_config,
26-
kerberos::kerberos_config_properties,
2727
};
2828

2929
#[derive(Snafu, Debug)]

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ pub const STACKABLE_LOG_DIR_NAME: &str = "log";
5454
pub const STACKABLE_LOG_CONFIG_MOUNT_DIR: &str = "/stackable/mount/log-config";
5555
pub const STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME: &str = "log-config-mount";
5656

57-
// Config file names
58-
// TODO(@maltesander): remove once fully consolidated with ConfigFileName
59-
pub const HIVE_SITE_XML: &str = "hive-site.xml";
60-
pub const HIVE_METASTORE_LOG4J2_PROPERTIES: &str = "metastore-log4j2.properties";
61-
pub const JVM_SECURITY_PROPERTIES_FILE: &str = "security.properties";
62-
6357
// Default ports
6458
pub const HIVE_PORT_NAME: &str = "hive";
6559
pub const HIVE_PORT: u16 = 9083;

0 commit comments

Comments
 (0)