Skip to content

Commit 9a98434

Browse files
maltesanderadwk67
andauthored
refactor: extract dereference/validate pipeline from reconcile (#1034)
* refactor(security): add sync ZookeeperSecurity::new constructor * refactor(zk_controller): extract dereference and validate steps * refactor(znode_controller): extract dereference and validate steps * refactor(security): drop async ZookeeperSecurity::new_from_zookeeper_cluster * chore: cargo +nightly fmt * chore(znode_controller): drop transitional comment on dereference call * fix: update crate hashes * feat: add smoke test snapshot * docs: adapt changelog * fix: remove image resolve from znode cleanup * Update rust/operator-binary/src/znode_controller.rs Co-authored-by: Andrew Kenworthy <1712947+adwk67@users.noreply.github.com> * fix(test): make configmap diff better readable * fix(smoke): revert failed cluster test --------- Co-authored-by: Andrew Kenworthy <1712947+adwk67@users.noreply.github.com>
1 parent b9aa771 commit 9a98434

15 files changed

Lines changed: 1099 additions & 344 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ All notable changes to this project will be documented in this file.
1515
`security.properties`).
1616
Previously, arbitrary file names were silently accepted and ignored ([#1027]).
1717
- Bump `stackable-operator` to 0.111.1 ([#1027], [#1028]).
18+
- Internal operator refactoring: introduce dereference() and validate() steps in the reconciler ([#1034]).
1819

1920
[#1020]: https://github.com/stackabletech/zookeeper-operator/pull/1020
2021
[#1027]: https://github.com/stackabletech/zookeeper-operator/pull/1027
2122
[#1028]: https://github.com/stackabletech/zookeeper-operator/pull/1028
23+
[#1034]: https://github.com/stackabletech/zookeeper-operator/pull/1034
2224

2325
## [26.3.0] - 2026-03-16
2426

Cargo.nix

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate-hashes.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,21 @@ use stackable_operator::{
1919
},
2020
},
2121
},
22-
client::Client,
2322
commons::secret_class::SecretClassVolumeProvisionParts,
2423
crd::authentication::core,
2524
k8s_openapi::api::core::v1::Volume,
2625
shared::time::Duration,
2726
};
2827

2928
use crate::{
30-
crd::{
31-
authentication::{self, ResolvedAuthenticationClasses},
32-
tls, v1alpha1,
33-
},
29+
crd::{authentication::ResolvedAuthenticationClasses, tls, v1alpha1},
3430
zk_controller::LISTENER_VOLUME_NAME,
3531
};
3632

3733
type Result<T, E = Error> = std::result::Result<T, E>;
3834

3935
#[derive(Snafu, Debug)]
4036
pub enum Error {
41-
#[snafu(display("failed to process authentication class"))]
42-
InvalidAuthenticationClassConfiguration { source: authentication::Error },
43-
4437
#[snafu(display("failed to build TLS volume for {volume_name:?}"))]
4538
BuildTlsVolume {
4639
source: SecretOperatorVolumeSourceBuilderError,
@@ -96,19 +89,15 @@ impl ZookeeperSecurity {
9689
pub const STORE_PASSWORD_ENV: &'static str = "STORE_PASSWORD";
9790
pub const SYSTEM_TRUST_STORE_DIR: &'static str = "/etc/pki/java/cacerts";
9891

99-
/// Create a `ZookeeperSecurity` struct from the Zookeeper custom resource and resolve
100-
/// all provided `AuthenticationClass` references.
101-
pub async fn new_from_zookeeper_cluster(
102-
client: &Client,
92+
/// Build a `ZookeeperSecurity` from a [`v1alpha1::ZookeeperCluster`] and already-resolved
93+
/// [`ResolvedAuthenticationClasses`]. Synchronous; intended to be called from the validate
94+
/// step of the controllers.
95+
pub fn new(
10396
zk: &v1alpha1::ZookeeperCluster,
104-
) -> Result<Self, Error> {
105-
Ok(ZookeeperSecurity {
106-
resolved_authentication_classes: authentication::resolve_authentication_classes(
107-
client,
108-
&zk.spec.cluster_config.authentication,
109-
)
110-
.await
111-
.context(InvalidAuthenticationClassConfigurationSnafu)?,
97+
resolved_authentication_classes: ResolvedAuthenticationClasses,
98+
) -> Self {
99+
ZookeeperSecurity {
100+
resolved_authentication_classes,
112101
server_secret_class: zk
113102
.spec
114103
.cluster_config
@@ -122,7 +111,7 @@ impl ZookeeperSecurity {
122111
.as_ref()
123112
.map(|tls| tls.quorum_secret_class.clone())
124113
.unwrap_or_else(tls::quorum_tls_default),
125-
})
114+
}
126115
}
127116

128117
/// Check if TLS encryption is enabled. This could be due to:

0 commit comments

Comments
 (0)