Skip to content

Commit 665cfba

Browse files
Merge branch 'refactor/remove-product-config' into use-improved-keyvalueconfigoverrides
2 parents 86ac135 + 5d90332 commit 665cfba

14 files changed

Lines changed: 287 additions & 283 deletions

File tree

rust/operator-binary/src/container.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ pub enum Error {
131131
source: ListenerOperatorVolumeSourceBuilderError,
132132
},
133133

134-
#[snafu(display("missing or invalid labels for the listener volume"))]
135-
ListenerVolumeLabels {
136-
source: ListenerOperatorVolumeSourceBuilderError,
137-
},
138-
139134
#[snafu(display("failed to configure logging"))]
140135
ConfigureLogging { source: LoggingError },
141136

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ use stackable_operator::{
1010
};
1111

1212
use crate::{
13-
controller::build::properties::{
14-
ConfigFileName, core_site, hadoop_policy, hdfs_site, logging, security_properties,
15-
ssl_client, ssl_server,
13+
controller::{
14+
ValidatedCluster,
15+
build::properties::{
16+
ConfigFileName, core_site, hadoop_policy, hdfs_site, logging, security_properties,
17+
ssl_client, ssl_server,
18+
},
1619
},
1720
crd::{HdfsNodeRole, v1alpha1},
18-
hdfs_controller::ValidatedCluster,
1921
};
2022

2123
#[derive(Snafu, Debug)]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use stackable_operator::{
1010
use crate::{
1111
build_recommended_labels,
1212
config::{CoreSiteConfigBuilder, HdfsSiteConfigBuilder},
13-
controller::build::properties::ConfigFileName,
13+
controller::{ValidatedCluster, build::properties::ConfigFileName},
1414
crd::{HdfsNodeRole, HdfsPodRef},
15-
hdfs_controller::{HDFS_CONTROLLER_NAME, ValidatedCluster},
15+
hdfs_controller::HDFS_CONTROLLER_NAME,
1616
security::kerberos::KerberosConfig,
1717
};
1818

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

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

77
use crate::{
8-
config::CoreSiteConfigBuilder, crd::HdfsNodeRole, hdfs_controller::ValidatedCluster,
8+
config::CoreSiteConfigBuilder, controller::ValidatedCluster, crd::HdfsNodeRole,
99
security::kerberos::KerberosConfig,
1010
};
1111

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ pub fn build(overrides: KeyValueConfigOverrides) -> String {
1515
#[cfg(test)]
1616
mod tests {
1717
use super::*;
18+
use crate::controller::build::properties::test_support::EMPTY_HADOOP_XML;
1819

1920
#[test]
2021
fn empty_overrides_render_empty_configuration() {
21-
assert_eq!(
22-
build(KeyValueConfigOverrides::default()),
23-
concat!(
24-
"<?xml version=\"1.0\"?>\n",
25-
"<configuration>\n",
26-
"</configuration>"
27-
)
28-
);
22+
assert_eq!(build(KeyValueConfigOverrides::default()), EMPTY_HADOOP_XML);
2923
}
3024

3125
#[test]

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

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

77
use crate::{
88
config::HdfsSiteConfigBuilder,
9+
controller::ValidatedCluster,
910
crd::{AnyNodeConfig, HdfsNodeRole},
10-
hdfs_controller::ValidatedCluster,
1111
};
1212

1313
/// Renders `hdfs-site.xml`: operator defaults, HA wiring derived from the pod

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! config file; the shared [`stackable_operator::v2::config_file_writer`]
44
//! module serializes maps to the Hadoop-XML / Java-properties on-wire format.
55
6+
use crate::container::{TLS_STORE_DIR, TLS_STORE_PASSWORD};
7+
68
pub mod core_site;
79
pub mod hadoop_policy;
810
pub mod hdfs_site;
@@ -11,6 +13,22 @@ pub mod security_properties;
1113
pub mod ssl_client;
1214
pub mod ssl_server;
1315

16+
/// The `<prefix>.truststore.*` entries (location, type, password) injected into
17+
/// `ssl-client.xml` / `ssl-server.xml` when HTTPS is enabled.
18+
fn truststore_entries(prefix: &str) -> [(String, String); 3] {
19+
[
20+
(
21+
format!("{prefix}.truststore.location"),
22+
format!("{TLS_STORE_DIR}/truststore.p12"),
23+
),
24+
(format!("{prefix}.truststore.type"), "pkcs12".to_string()),
25+
(
26+
format!("{prefix}.truststore.password"),
27+
TLS_STORE_PASSWORD.to_string(),
28+
),
29+
]
30+
}
31+
1432
/// The names of the HDFS config files assembled into the rolegroup `ConfigMap`.
1533
#[derive(Clone, Copy, Debug, strum::Display)]
1634
pub enum ConfigFileName {
@@ -53,9 +71,17 @@ pub(crate) mod test_support {
5371
};
5472

5573
use crate::{
56-
controller::validate::validate_cluster, crd::v1alpha1, hdfs_controller::ValidatedCluster,
74+
controller::{ValidatedCluster, validate::validate_cluster},
75+
crd::v1alpha1,
5776
};
5877

78+
/// The rendered output of an empty Hadoop-XML configuration (no entries).
79+
pub const EMPTY_HADOOP_XML: &str = concat!(
80+
"<?xml version=\"1.0\"?>\n",
81+
"<configuration>\n",
82+
"</configuration>"
83+
);
84+
5985
/// A minimal three-role HdfsCluster used to drive the per-file builder tests.
6086
pub const MINIMAL_HDFS_YAML: &str = r#"
6187
---

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

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,13 @@ use stackable_operator::v2::{
99
config_file_writer::to_hadoop_xml, config_overrides::KeyValueConfigOverrides,
1010
};
1111

12-
use crate::container::{TLS_STORE_DIR, TLS_STORE_PASSWORD};
12+
use crate::controller::build::properties::truststore_entries;
1313

1414
/// Renders `ssl-client.xml` for the given HTTPS state and user overrides.
1515
pub fn build(https_enabled: bool, overrides: KeyValueConfigOverrides) -> String {
1616
let mut config: BTreeMap<String, String> = BTreeMap::new();
1717
if https_enabled {
18-
config.extend([
19-
(
20-
"ssl.client.truststore.location".to_string(),
21-
format!("{TLS_STORE_DIR}/truststore.p12"),
22-
),
23-
(
24-
"ssl.client.truststore.type".to_string(),
25-
"pkcs12".to_string(),
26-
),
27-
(
28-
"ssl.client.truststore.password".to_string(),
29-
TLS_STORE_PASSWORD.to_string(),
30-
),
31-
]);
18+
config.extend(truststore_entries("ssl.client"));
3219
}
3320
// Overrides applied last so users win.
3421
config.extend(overrides);
@@ -38,16 +25,16 @@ pub fn build(https_enabled: bool, overrides: KeyValueConfigOverrides) -> String
3825
#[cfg(test)]
3926
mod tests {
4027
use super::*;
28+
use crate::{
29+
container::{TLS_STORE_DIR, TLS_STORE_PASSWORD},
30+
controller::build::properties::test_support::EMPTY_HADOOP_XML,
31+
};
4132

4233
#[test]
4334
fn disabled_https_without_overrides_renders_empty_configuration() {
4435
assert_eq!(
4536
build(false, KeyValueConfigOverrides::default()),
46-
concat!(
47-
"<?xml version=\"1.0\"?>\n",
48-
"<configuration>\n",
49-
"</configuration>"
50-
)
37+
EMPTY_HADOOP_XML
5138
);
5239
}
5340

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

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,17 @@ use stackable_operator::v2::{
99
config_file_writer::to_hadoop_xml, config_overrides::KeyValueConfigOverrides,
1010
};
1111

12-
use crate::container::{TLS_STORE_DIR, TLS_STORE_PASSWORD};
12+
use crate::{
13+
container::{TLS_STORE_DIR, TLS_STORE_PASSWORD},
14+
controller::build::properties::truststore_entries,
15+
};
1316

1417
/// Renders `ssl-server.xml` for the given HTTPS state and user overrides.
1518
pub fn build(https_enabled: bool, overrides: KeyValueConfigOverrides) -> String {
1619
let mut config: BTreeMap<String, String> = BTreeMap::new();
1720
if https_enabled {
21+
config.extend(truststore_entries("ssl.server"));
1822
config.extend([
19-
(
20-
"ssl.server.truststore.location".to_string(),
21-
format!("{TLS_STORE_DIR}/truststore.p12"),
22-
),
23-
(
24-
"ssl.server.truststore.type".to_string(),
25-
"pkcs12".to_string(),
26-
),
27-
(
28-
"ssl.server.truststore.password".to_string(),
29-
TLS_STORE_PASSWORD.to_string(),
30-
),
3123
(
3224
"ssl.server.keystore.location".to_string(),
3325
format!("{TLS_STORE_DIR}/keystore.p12"),
@@ -47,16 +39,13 @@ pub fn build(https_enabled: bool, overrides: KeyValueConfigOverrides) -> String
4739
#[cfg(test)]
4840
mod tests {
4941
use super::*;
42+
use crate::controller::build::properties::test_support::EMPTY_HADOOP_XML;
5043

5144
#[test]
5245
fn disabled_https_without_overrides_renders_empty_configuration() {
5346
assert_eq!(
5447
build(false, KeyValueConfigOverrides::default()),
55-
concat!(
56-
"<?xml version=\"1.0\"?>\n",
57-
"<configuration>\n",
58-
"</configuration>"
59-
)
48+
EMPTY_HADOOP_XML
6049
);
6150
}
6251

0 commit comments

Comments
 (0)