@@ -27,7 +27,6 @@ use stackable_operator::{
2727 } ,
2828 kvp:: Labels ,
2929 logging:: controller:: ReconcilerError ,
30- role_utils:: GenericRoleConfig ,
3130 shared:: time:: Duration ,
3231 status:: condition:: {
3332 compute_conditions, operations:: ClusterOperationsConditionBuilder ,
@@ -119,17 +118,21 @@ pub struct ValidatedCluster {
119118 /// value.
120119 pub product_version : ProductVersion ,
121120 pub cluster_config : ValidatedClusterConfig ,
121+ /// Per-role configuration (e.g. the Pod disruption budget), keyed by role.
122+ pub role_configs : BTreeMap < KafkaRole , ValidatedRoleConfig > ,
122123 pub role_group_configs : BTreeMap < KafkaRole , BTreeMap < RoleGroupName , ValidatedRoleGroupConfig > > ,
123124}
124125
125126impl ValidatedCluster {
127+ #[ allow( clippy:: too_many_arguments) ]
126128 pub fn new (
127129 name : ClusterName ,
128130 namespace : NamespaceName ,
129131 uid : Uid ,
130132 cluster_domain : DomainName ,
131133 image : ResolvedProductImage ,
132134 cluster_config : ValidatedClusterConfig ,
135+ role_configs : BTreeMap < KafkaRole , ValidatedRoleConfig > ,
133136 role_group_configs : BTreeMap < KafkaRole , BTreeMap < RoleGroupName , ValidatedRoleGroupConfig > > ,
134137 ) -> Self {
135138 // `app_version_label_value` is constructed to be a valid label value, so it is also a
@@ -150,6 +153,7 @@ impl ValidatedCluster {
150153 image,
151154 product_version,
152155 cluster_config,
156+ role_configs,
153157 role_group_configs,
154158 }
155159 }
@@ -365,6 +369,15 @@ impl ValidatedClusterConfig {
365369 }
366370}
367371
372+ /// Per-role configuration extracted during validation.
373+ ///
374+ /// Resolved from the raw [`v1alpha1::KafkaCluster`] spec during validation so the reconcile loop
375+ /// never has to read it. Kafka's `GenericRoleConfig` only carries the Pod disruption budget.
376+ #[ derive( Clone , Debug ) ]
377+ pub struct ValidatedRoleConfig {
378+ pub pdb : stackable_operator:: commons:: pdb:: PdbConfig ,
379+ }
380+
368381/// Lets [`ValidatedCluster`] act as the owner [`Resource`] for child objects, so owner
369382/// references are built from it (via the captured `metadata`) rather than the raw CR.
370383impl Resource for ValidatedCluster {
@@ -706,11 +719,8 @@ pub async fn reconcile_kafka(
706719 ) ;
707720 }
708721
709- let role_cfg = kafka. role_config ( kafka_role) ;
710- if let Some ( GenericRoleConfig {
711- pod_disruption_budget : pdb,
712- } ) = role_cfg
713- && let Some ( pdb) = build_pdb ( pdb, & validated_cluster, kafka_role)
722+ if let Some ( role_config) = validated_cluster. role_configs . get ( kafka_role)
723+ && let Some ( pdb) = build_pdb ( & role_config. pdb , & validated_cluster, kafka_role)
714724 {
715725 cluster_resources
716726 . add ( client, pdb)
0 commit comments