Skip to content

Commit a9d7144

Browse files
authored
fix: Prevent missing certificates (#611)
* fix: Prevent missing certificates * changelog * test: Increase timeouts
1 parent 3394071 commit a9d7144

File tree

13 files changed

+28
-30
lines changed

13 files changed

+28
-30
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ All notable changes to this project will be documented in this file.
1313
### Fixed
1414

1515
- SparkConnectServer: The `imagePullSecret` is now correctly passed to Spark executor pods ([#603]).
16+
- Previously we had a bug that could lead to missing certificates ([#611]).
17+
18+
This could be the case when you specified multiple CAs in your SecretClass.
19+
We now correctly handle multiple certificates in this cases.
20+
See [this GitHub issue](https://github.com/stackabletech/issues/issues/764) for details
1621

1722
### Removed
1823

@@ -22,6 +27,7 @@ All notable changes to this project will be documented in this file.
2227
[#603]: https://github.com/stackabletech/spark-k8s-operator/pull/603
2328
[#608]: https://github.com/stackabletech/spark-k8s-operator/pull/608
2429
[#610]: https://github.com/stackabletech/spark-k8s-operator/pull/610
30+
[#611]: https://github.com/stackabletech/spark-k8s-operator/pull/611
2531

2632
## [25.7.0] - 2025-07-23
2733

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ pub const METRICS_PROPERTIES_FILE: &str = "metrics.properties";
3838
pub const ACCESS_KEY_ID: &str = "accessKey";
3939
pub const SECRET_ACCESS_KEY: &str = "secretKey";
4040
pub const S3_SECRET_DIR_NAME: &str = "/stackable/secrets";
41-
pub const SYSTEM_TRUST_STORE: &str = "/etc/pki/java/cacerts";
4241
pub const STACKABLE_TRUST_STORE: &str = "/stackable/truststore";
4342
pub const STACKABLE_TRUST_STORE_NAME: &str = "stackable-truststore";
4443
pub const STACKABLE_TLS_STORE_PASSWORD: &str = "changeit";
45-
pub const SYSTEM_TRUST_STORE_PASSWORD: &str = "changeit";
4644
pub const STACKABLE_MOUNT_PATH_TLS: &str = "/stackable/mount_server_tls";
4745

4846
pub const MIN_MEMORY_OVERHEAD: u32 = 384;

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ use stackable_operator::{
66
};
77

88
use crate::crd::{
9-
constants::{
10-
STACKABLE_MOUNT_PATH_TLS, STACKABLE_TLS_STORE_PASSWORD, STACKABLE_TRUST_STORE,
11-
SYSTEM_TRUST_STORE, SYSTEM_TRUST_STORE_PASSWORD,
12-
},
9+
constants::{STACKABLE_MOUNT_PATH_TLS, STACKABLE_TLS_STORE_PASSWORD, STACKABLE_TRUST_STORE},
1310
logdir::ResolvedLogDir,
1411
};
1512

@@ -52,20 +49,17 @@ pub fn tls_secret_names<'a>(
5249
if names.is_empty() { None } else { Some(names) }
5350
}
5451

55-
pub fn convert_system_trust_store_to_pkcs12() -> Vec<String> {
56-
vec![format!(
57-
"keytool -importkeystore -srckeystore {SYSTEM_TRUST_STORE} -srcstoretype jks -srcstorepass {SYSTEM_TRUST_STORE_PASSWORD} -destkeystore {STACKABLE_TRUST_STORE}/truststore.p12 -deststoretype pkcs12 -deststorepass {STACKABLE_TLS_STORE_PASSWORD} -noprompt"
58-
)]
52+
pub fn convert_system_trust_store_to_pkcs12() -> String {
53+
format!(
54+
"cert-tools generate-pkcs12-truststore --pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem --out {STACKABLE_TRUST_STORE}/truststore.p12 --out-password {STACKABLE_TLS_STORE_PASSWORD}"
55+
)
5956
}
6057

61-
pub fn import_truststore(secret_name: &str) -> Vec<String> {
58+
pub fn import_truststore(secret_name: &str) -> String {
6259
let mount_trust_store_path = format!("{STACKABLE_MOUNT_PATH_TLS}/{secret_name}/truststore.p12");
6360
let trust_store_path = format!("{STACKABLE_TRUST_STORE}/truststore.p12");
6461

65-
vec![
66-
format!("echo Importing [{mount_trust_store_path}] to [{trust_store_path}] ..."),
67-
format!(
68-
"keytool -importkeystore -srckeystore {mount_trust_store_path} -srcalias 1 -srcstorepass \"\" -destkeystore {trust_store_path} -destalias stackable-{secret_name} -storepass {STACKABLE_TLS_STORE_PASSWORD} -noprompt"
69-
),
70-
]
62+
format!(
63+
"cert-tools generate-pkcs12-truststore --pkcs12 {trust_store_path}:{STACKABLE_TLS_STORE_PASSWORD} --pkcs12 {mount_trust_store_path} --out {trust_store_path} --out-password {STACKABLE_TLS_STORE_PASSWORD}"
64+
)
7165
}

rust/operator-binary/src/history/history_controller.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ fn command_args(logdir: &ResolvedLogDir) -> Vec<String> {
720720
}
721721

722722
if let Some(secret_name) = logdir.tls_secret_name() {
723-
command.extend(vec![format!("mkdir -p {STACKABLE_TRUST_STORE}")]);
724-
command.extend(tlscerts::convert_system_trust_store_to_pkcs12());
725-
command.extend(tlscerts::import_truststore(secret_name));
723+
command.push(format!("mkdir -p {STACKABLE_TRUST_STORE}"));
724+
command.push(tlscerts::convert_system_trust_store_to_pkcs12());
725+
command.push(tlscerts::import_truststore(secret_name));
726726
}
727727

728728
command.extend(vec![

rust/operator-binary/src/spark_k8s_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ fn init_containers(
542542

543543
let tls_container = match tlscerts::tls_secret_names(s3conn, logdir) {
544544
Some(cert_secrets) => {
545-
args.extend(tlscerts::convert_system_trust_store_to_pkcs12());
545+
args.push(tlscerts::convert_system_trust_store_to_pkcs12());
546546
for cert_secret in cert_secrets {
547-
args.extend(tlscerts::import_truststore(cert_secret));
547+
args.push(tlscerts::import_truststore(cert_secret));
548548
tcb.add_volume_mount(
549549
cert_secret,
550550
format!("{STACKABLE_MOUNT_PATH_TLS}/{cert_secret}"),

tests/templates/kuttl/delta-lake/40-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 300
4+
timeout: 900
55
---
66
# The Job starting the whole process
77
apiVersion: spark.stackable.tech/v1alpha1

tests/templates/kuttl/iceberg/10-assert.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 300
4+
timeout: 900
55
---
66
# The Job starting the whole process
77
apiVersion: spark.stackable.tech/v1alpha1

tests/templates/kuttl/overrides/06-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 300
4+
timeout: 900
55
---
66
apiVersion: apps/v1
77
kind: StatefulSet

tests/templates/kuttl/overrides/10-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 300
4+
timeout: 600
55
---
66
apiVersion: spark.stackable.tech/v1alpha1
77
kind: SparkApplication

tests/templates/kuttl/resources/10-assert.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 240
4+
timeout: 600
55
---
66
apiVersion: v1
77
kind: Pod

0 commit comments

Comments
 (0)