Skip to content

Commit 7736b5e

Browse files
committed
refactor: remove more rolegroupref references.
1 parent 3cebee3 commit 7736b5e

4 files changed

Lines changed: 17 additions & 40 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use stackable_operator::{
2727
},
2828
kvp::Labels,
2929
logging::controller::ReconcilerError,
30-
role_utils::{GenericRoleConfig, RoleGroupRef},
30+
role_utils::GenericRoleConfig,
3131
shared::time::Duration,
3232
status::condition::{
3333
compute_conditions, operations::ClusterOperationsConditionBuilder,
@@ -437,22 +437,22 @@ pub enum Error {
437437
source: stackable_operator::cluster_resources::Error,
438438
},
439439

440-
#[snafu(display("failed to apply Service for {}", rolegroup))]
440+
#[snafu(display("failed to apply Service for role group {role_group}"))]
441441
ApplyRoleGroupService {
442442
source: stackable_operator::cluster_resources::Error,
443-
rolegroup: RoleGroupRef<v1alpha1::KafkaCluster>,
443+
role_group: RoleGroupName,
444444
},
445445

446-
#[snafu(display("failed to apply ConfigMap for {}", rolegroup))]
446+
#[snafu(display("failed to apply ConfigMap for role group {role_group}"))]
447447
ApplyRoleGroupConfig {
448448
source: stackable_operator::cluster_resources::Error,
449-
rolegroup: RoleGroupRef<v1alpha1::KafkaCluster>,
449+
role_group: RoleGroupName,
450450
},
451451

452-
#[snafu(display("failed to apply StatefulSet for {}", rolegroup))]
452+
#[snafu(display("failed to apply StatefulSet for role group {role_group}"))]
453453
ApplyRoleGroupStatefulSet {
454454
source: stackable_operator::cluster_resources::Error,
455-
rolegroup: RoleGroupRef<v1alpha1::KafkaCluster>,
455+
role_group: RoleGroupName,
456456
},
457457

458458
#[snafu(display("failed to build discovery ConfigMap"))]
@@ -605,10 +605,6 @@ pub async fn reconcile_kafka(
605605

606606
for (kafka_role, rg_map) in &validated_cluster.role_group_configs {
607607
for (rolegroup_name, validated_rg) in rg_map {
608-
// `rolegroup_ref` is a v1 `RoleGroupRef` retained only for the error context of the
609-
// per-rolegroup apply calls below. All other identification uses the typed
610-
// `kafka_role` / `rolegroup_name` (and `ValidatedCluster::resource_names`).
611-
let rolegroup_ref = kafka.rolegroup_ref(kafka_role, rolegroup_name.to_string());
612608
// The Vector agent config is the static `vector.yaml`, added to the rolegroup
613609
// ConfigMap only when the Vector agent is enabled (resolved during validation).
614610
let vector_config = validated_rg
@@ -682,19 +678,19 @@ pub async fn reconcile_kafka(
682678
.add(client, rg_headless_service)
683679
.await
684680
.with_context(|_| ApplyRoleGroupServiceSnafu {
685-
rolegroup: rolegroup_ref.clone(),
681+
role_group: rolegroup_name.clone(),
686682
})?;
687683
cluster_resources
688684
.add(client, rg_metrics_service)
689685
.await
690686
.with_context(|_| ApplyRoleGroupServiceSnafu {
691-
rolegroup: rolegroup_ref.clone(),
687+
role_group: rolegroup_name.clone(),
692688
})?;
693689
cluster_resources
694690
.add(client, rg_configmap)
695691
.await
696692
.with_context(|_| ApplyRoleGroupConfigSnafu {
697-
rolegroup: rolegroup_ref.clone(),
693+
role_group: rolegroup_name.clone(),
698694
})?;
699695

700696
// Note: The StatefulSet needs to be applied after all ConfigMaps and Secrets it mounts
@@ -705,7 +701,7 @@ pub async fn reconcile_kafka(
705701
.add(client, rg_statefulset)
706702
.await
707703
.with_context(|_| ApplyRoleGroupStatefulSetSnafu {
708-
rolegroup: rolegroup_ref.clone(),
704+
role_group: rolegroup_name.clone(),
709705
})?,
710706
);
711707
}

rust/operator-binary/src/controller/build/properties/product_logging/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const CONSOLE_CONVERSION_PATTERN_LOG4J2: &str = "%d{ISO8601} %p [%t] %c - %m%n";
4141

4242
/// Get the role group ConfigMap data with the log4j/log4j2 logging configuration.
4343
///
44-
/// The Vector agent config is built separately via [`build_vector_config`] (which needs a
45-
/// [`RoleGroupRef`]) and added by the caller.
44+
/// The Vector agent config (`vector.yaml`) is provided separately via
45+
/// [`vector_config_file_content`] and added by the caller.
4646
pub fn role_group_config_map_data(
4747
product_version: &str,
4848
merged_config: &AnyConfig,

rust/operator-binary/src/controller/build/resource/config_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ pub enum Error {
5858

5959
/// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator.
6060
///
61-
/// `vector_config` is the Vector agent config built by the caller (where a `RoleGroupRef` is
62-
/// available); it is `None` when the Vector agent is disabled. Resource naming and labels use the
63-
/// role (derived from `validated_rg.config`) and the typed `role_group_name`.
61+
/// `vector_config` is the static Vector agent config (`vector.yaml`) added by the caller; it is
62+
/// `None` when the Vector agent is disabled. Resource naming and labels use the role (derived
63+
/// from `validated_rg.config`) and the typed `role_group_name`.
6464
pub fn build_rolegroup_config_map(
6565
validated_cluster: &ValidatedCluster,
6666
role_group_name: &RoleGroupName,

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use stackable_operator::{
1717
config::merge::Merge,
1818
deep_merger::ObjectOverrides,
1919
kube::{CustomResource, runtime::reflector::ObjectRef},
20-
role_utils::{GenericRoleConfig, Role, RoleGroupRef},
20+
role_utils::{GenericRoleConfig, Role},
2121
schemars::{self, JsonSchema},
2222
status::condition::{ClusterCondition, HasStatusCondition},
2323
v2::{
@@ -321,19 +321,6 @@ impl v1alpha1::KafkaCluster {
321321
})
322322
}
323323

324-
/// Metadata about a rolegroup
325-
pub fn rolegroup_ref(
326-
&self,
327-
role: &KafkaRole,
328-
group_name: impl Into<String>,
329-
) -> RoleGroupRef<Self> {
330-
RoleGroupRef {
331-
cluster: ObjectRef::from_obj(self),
332-
role: role.to_string(),
333-
role_group: group_name.into(),
334-
}
335-
}
336-
337324
pub fn role_config(&self, role: &KafkaRole) -> Option<&GenericRoleConfig> {
338325
match role {
339326
KafkaRole::Broker => self.spec.brokers.as_ref().map(|b| &b.role_config),
@@ -346,12 +333,6 @@ impl v1alpha1::KafkaCluster {
346333
role: KafkaRole::Broker.to_string(),
347334
})
348335
}
349-
350-
pub fn controller_role(&self) -> Result<&ControllerRole, Error> {
351-
self.spec.controllers.as_ref().context(MissingRoleSnafu {
352-
role: KafkaRole::Controller.to_string(),
353-
})
354-
}
355336
}
356337

357338
/// Reference to a single `Pod` that is a component of a [`KafkaCluster`]

0 commit comments

Comments
 (0)