@@ -15,6 +15,7 @@ use stackable_operator::{
1515 cli:: OperatorEnvironmentOptions ,
1616 commons:: {
1717 cluster_operation:: ClusterOperation ,
18+ pdb:: PdbConfig ,
1819 product_image_selection:: { self , ResolvedProductImage } ,
1920 } ,
2021 config:: fragment,
@@ -215,6 +216,9 @@ pub struct ValidatedCluster {
215216 /// `app.kubernetes.io/version` label. Derived from the resolved image's app version label value.
216217 pub product_version : ProductVersion ,
217218 pub cluster_config : ValidatedClusterConfig ,
219+ /// Per-role config (currently just the PodDisruptionBudget), extracted during validation so the
220+ /// apply step does not reach into the raw [`crate::crd::v1alpha1::ZookeeperCluster`].
221+ pub role_config : Option < ValidatedRoleConfig > ,
218222 pub role_group_configs :
219223 BTreeMap < ZookeeperRole , BTreeMap < RoleGroupName , ValidatedRoleGroupConfig > > ,
220224 /// The cluster's operation settings (pause/stop), from which the
@@ -235,6 +239,7 @@ impl ValidatedCluster {
235239 image : ResolvedProductImage ,
236240 product_version : ProductVersion ,
237241 cluster_config : ValidatedClusterConfig ,
242+ role_config : Option < ValidatedRoleConfig > ,
238243 role_group_configs : BTreeMap <
239244 ZookeeperRole ,
240245 BTreeMap < RoleGroupName , ValidatedRoleGroupConfig > ,
@@ -255,6 +260,7 @@ impl ValidatedCluster {
255260 image,
256261 product_version,
257262 cluster_config,
263+ role_config,
258264 role_group_configs,
259265 cluster_operation,
260266 object_overrides,
@@ -416,6 +422,12 @@ pub struct ValidatedClusterConfig {
416422 pub listener_class : ListenerClassName ,
417423}
418424
425+ /// Per-role configuration extracted during validation.
426+ #[ derive( Clone , Debug ) ]
427+ pub struct ValidatedRoleConfig {
428+ pub pdb : PdbConfig ,
429+ }
430+
419431/// Validates the cluster spec and the dereferenced inputs.
420432pub fn validate (
421433 zk : & v1alpha1:: ZookeeperCluster ,
@@ -496,6 +508,12 @@ pub fn validate(
496508 cluster_info,
497509 ) ;
498510
511+ let role_config = zk. role_config ( & ZookeeperRole :: Server ) . map (
512+ |ZookeeperServerRoleConfig { common, .. } | ValidatedRoleConfig {
513+ pdb : common. pod_disruption_budget . clone ( ) ,
514+ } ,
515+ ) ;
516+
499517 Ok ( ValidatedCluster :: new (
500518 name,
501519 namespace,
@@ -507,6 +525,7 @@ pub fn validate(
507525 server_addresses,
508526 listener_class,
509527 } ,
528+ role_config,
510529 role_group_configs,
511530 zk. spec . cluster_operation . clone ( ) ,
512531 zk. spec . object_overrides . clone ( ) ,
0 commit comments