From dcd8e9934bedaa8eef911ed41f7ecc048a833412 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 22 Apr 2026 16:37:22 +0200 Subject: [PATCH 1/5] feat: Add DerbyConnection::jdbc_connection_details_with_host_part helper --- .../database_connections/databases/derby.rs | 61 ++++++++++++++++--- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/crates/stackable-operator/src/database_connections/databases/derby.rs b/crates/stackable-operator/src/database_connections/databases/derby.rs index 1ea4c8b6f..72bcb4c31 100644 --- a/crates/stackable-operator/src/database_connections/databases/derby.rs +++ b/crates/stackable-operator/src/database_connections/databases/derby.rs @@ -49,14 +49,43 @@ impl JdbcDatabaseConnection for DerbyConnection { unique_database_name: &str, _templating_mechanism: &TemplatingMechanism, ) -> Result { - let location = self.location.as_ref_or_else(|| { - PathBuf::from(format!("/tmp/derby/{unique_database_name}/derby.db")) - }); - let location = location.to_str().with_context(|| NonUtf8LocationSnafu { - location: location.to_path_buf(), - })?; - let connection_url = format!("jdbc:derby:{location};create=true",); - let connection_url = connection_url.parse().context(ParseConnectionUrlSnafu)?; + let location = self.location(unique_database_name)?; + let connection_url = format!("jdbc:derby:{location};create=true") + .parse() + .context(ParseConnectionUrlSnafu)?; + + Ok(JdbcDatabaseConnectionDetails { + driver: DERBY_JDBC_DRIVER_CLASS.to_owned(), + connection_url, + username_env: None, + password_env: None, + }) + } +} + +impl DerbyConnection { + /// Returns the JDBC connection URL in a format such as + /// `jdbc:derby://localhost:1527//opt/var/druid_state/derby;create=true`. + /// + /// E.g. according to the [Druid docs](https://druid.apache.org/docs/latest/design/metadata-storage/#derby) + /// we should configure something like + /// `jdbc:derby://localhost:1527//opt/var/druid_state/derby;create=true`. + /// + /// Druid actually starts a Derby instance, which listens on `127.0.0.1:1527`. The schema seems + /// to be the filesystem location. + /// + /// As stackable-operator generates a (correct) URL in the form + /// `jdbc:derby:/tmp/foo/bar.db;create=true`, this function converts it to + /// `jdbc:derby://dummy-host-for-druid:1234/tmp/foo/bar.db;create=true` + pub fn jdbc_connection_details_with_host_part( + &self, + unique_database_name: &str, + host_part: &str, + ) -> Result { + let location = self.location(unique_database_name)?; + let connection_url = format!("jdbc:derby://{host_part}/{location};create=true") + .parse() + .context(ParseConnectionUrlSnafu)?; Ok(JdbcDatabaseConnectionDetails { driver: DERBY_JDBC_DRIVER_CLASS.to_owned(), @@ -65,4 +94,20 @@ impl JdbcDatabaseConnection for DerbyConnection { password_env: None, }) } + + /// Returns the configured [`Self::location`] or a sensible default value + fn location( + &self, + unique_database_name: &str, + ) -> Result { + let location = self.location.as_ref_or_else(|| { + PathBuf::from(format!("/tmp/derby/{unique_database_name}/derby.db")) + }); + Ok(location + .to_str() + .with_context(|| NonUtf8LocationSnafu { + location: location.to_path_buf(), + })? + .to_owned()) + } } From 1d059173ba8bcfc9ee24e9ad3d16a07d4afc1781 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 22 Apr 2026 16:45:08 +0200 Subject: [PATCH 2/5] docs --- .../src/database_connections/databases/derby.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/stackable-operator/src/database_connections/databases/derby.rs b/crates/stackable-operator/src/database_connections/databases/derby.rs index 72bcb4c31..569fad7b3 100644 --- a/crates/stackable-operator/src/database_connections/databases/derby.rs +++ b/crates/stackable-operator/src/database_connections/databases/derby.rs @@ -73,10 +73,6 @@ impl DerbyConnection { /// /// Druid actually starts a Derby instance, which listens on `127.0.0.1:1527`. The schema seems /// to be the filesystem location. - /// - /// As stackable-operator generates a (correct) URL in the form - /// `jdbc:derby:/tmp/foo/bar.db;create=true`, this function converts it to - /// `jdbc:derby://dummy-host-for-druid:1234/tmp/foo/bar.db;create=true` pub fn jdbc_connection_details_with_host_part( &self, unique_database_name: &str, From ab758cd3b867338ae92988d3343ea29770ab5e08 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 24 Apr 2026 13:29:18 +0200 Subject: [PATCH 3/5] cargo update --- Cargo.lock | 89 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60cd40dd6..992298ac3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -381,11 +381,12 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const_format" -version = "0.2.35" +version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad" +checksum = "4481a617ad9a412be3b97c5d403fef8ed023103368908b9c50af598ff467cc1e" dependencies = [ "const_format_proc_macros", + "konst", ] [[package]] @@ -1431,9 +1432,9 @@ dependencies = [ [[package]] name = "jiff" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a3546dc96b6d42c5f24902af9e2538e82e39ad350b0c766eb3fbf2d8f3d8359" +checksum = "f00b5dbd620d61dfdcb6007c9c1f6054ebd75319f163d886a9055cec1155073d" dependencies = [ "jiff-static", "jiff-tzdb-platform", @@ -1446,9 +1447,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a8c8b344124222efd714b73bb41f8b5120b27a7cc1c75593a6ff768d9d05aa4" +checksum = "e000de030ff8022ea1da3f466fbb0f3a809f5e51ed31f6dd931c35181ad8e6d7" dependencies = [ "proc-macro2", "quote", @@ -1546,6 +1547,21 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "konst" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128133ed7824fcd73d6e7b17957c5eb7bacb885649bd8c69708b2331a10bcefb" +dependencies = [ + "konst_macro_rules", +] + +[[package]] +name = "konst_macro_rules" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" + [[package]] name = "kube" version = "3.1.0" @@ -1672,9 +1688,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.185" +version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libm" @@ -1777,7 +1793,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand 0.8.5", + "rand 0.8.6", "smallvec", "zeroize", ] @@ -2109,9 +2125,9 @@ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "portable-atomic-util" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "091397be61a01d4be58e7841595bd4bfedb15f1cd54977d79b8271e94ed799a3" +checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" dependencies = [ "portable-atomic", ] @@ -2239,9 +2255,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" dependencies = [ "libc", "rand_chacha 0.3.1", @@ -2475,7 +2491,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3a8fb4672e840a587a66fc577a5491375df51ddb88f2a2c2a792598c326fe14" dependencies = [ "quote", - "rand 0.8.5", + "rand 0.8.6", "syn 2.0.117", ] @@ -2503,9 +2519,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.38" +version = "0.23.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69f9466fb2c14ea04357e91413efb882e2a6d4a406e625449bc0a5d360d53a21" +checksum = "7c2c118cb077cca2822033836dfb1b975355dfb784b5e8da48f7b6c5db74e60e" dependencies = [ "log", "once_cell", @@ -2539,9 +2555,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.12" +version = "0.103.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8279bb85272c9f10811ae6a6c547ff594d6a7f3c6c6b02ee9726d1d0dcfcdd06" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" dependencies = [ "ring", "rustls-pki-types", @@ -3177,6 +3193,12 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "symlink" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" + [[package]] name = "syn" version = "1.0.109" @@ -3360,9 +3382,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.52.0" +version = "1.52.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91135f59b1cbf38c91e73cf3386fca9bb77915c45ce2771460c9d92f0f3d776" +checksum = "b67dee974fe86fd92cc45b7a95fdd2f99a36a6d7b0d431a231178d3d670bbcc6" dependencies = [ "bytes", "libc", @@ -3587,11 +3609,12 @@ dependencies = [ [[package]] name = "tracing-appender" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786d480bce6247ab75f005b14ae1624ad978d3029d9113f0a22fa1ac773faeaf" +checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c" dependencies = [ "crossbeam-channel", + "symlink", "thiserror 2.0.18", "time", "tracing-subscriber", @@ -3716,9 +3739,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" [[package]] name = "ucd-trie" @@ -3826,11 +3849,11 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.2+wasi-0.2.9" +version = "1.0.3+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" dependencies = [ - "wit-bindgen", + "wit-bindgen 0.57.1", ] [[package]] @@ -3839,7 +3862,7 @@ version = "0.4.0+wasi-0.3.0-rc-2026-01-06" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" dependencies = [ - "wit-bindgen", + "wit-bindgen 0.51.0", ] [[package]] @@ -4050,9 +4073,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09dac053f1cd375980747450bfc7250c264eaae0583872e845c0c7cd578872b5" +checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0" dependencies = [ "memchr", ] @@ -4066,6 +4089,12 @@ dependencies = [ "wit-bindgen-rust-macro", ] +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + [[package]] name = "wit-bindgen-core" version = "0.51.0" From d9e9c721759ccd23a7bfc133447cf7a1fd475c5f Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 24 Apr 2026 13:30:51 +0200 Subject: [PATCH 4/5] changelog --- crates/stackable-operator/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 54eabd978..cdda01a23 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -9,8 +9,10 @@ All notable changes to this project will be documented in this file. ### Added - Derive `strum::AsRefStr` for `ClientAuthenticationMethod` ([#1197]). +- Add `DerbyConnection::jdbc_connection_details_with_host_part` helper ([#1200]). [#1197]: https://github.com/stackabletech/operator-rs/pull/1197 +[#1200]: https://github.com/stackabletech/operator-rs/pull/1200 ## [0.110.0] - 2026-04-10 From 71788ad8e17f0a79ffafa832ad6969e441e0d08d Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 24 Apr 2026 13:31:54 +0200 Subject: [PATCH 5/5] Rename to jdbc_connection_details_for_network_access --- crates/stackable-operator/CHANGELOG.md | 2 +- .../src/database_connections/databases/derby.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index cdda01a23..17d3f9b23 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file. ### Added - Derive `strum::AsRefStr` for `ClientAuthenticationMethod` ([#1197]). -- Add `DerbyConnection::jdbc_connection_details_with_host_part` helper ([#1200]). +- Add `DerbyConnection::jdbc_connection_details_for_network_access` helper ([#1200]). [#1197]: https://github.com/stackabletech/operator-rs/pull/1197 [#1200]: https://github.com/stackabletech/operator-rs/pull/1200 diff --git a/crates/stackable-operator/src/database_connections/databases/derby.rs b/crates/stackable-operator/src/database_connections/databases/derby.rs index 569fad7b3..0c153d802 100644 --- a/crates/stackable-operator/src/database_connections/databases/derby.rs +++ b/crates/stackable-operator/src/database_connections/databases/derby.rs @@ -73,7 +73,7 @@ impl DerbyConnection { /// /// Druid actually starts a Derby instance, which listens on `127.0.0.1:1527`. The schema seems /// to be the filesystem location. - pub fn jdbc_connection_details_with_host_part( + pub fn jdbc_connection_details_for_network_access( &self, unique_database_name: &str, host_part: &str,