Skip to content

Commit 42f0076

Browse files
committed
refactor: fold the discovery ConfigMap into the build aggregator
1 parent fc5daf4 commit 42f0076

2 files changed

Lines changed: 9 additions & 27 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::controller::{
1212
KubernetesResources, ValidatedCluster,
1313
build::resource::{
1414
config_map::{self, build_rolegroup_config_map},
15+
discovery::{self, build_discovery_config_map},
1516
pdb::build_pdb,
1617
service::{build_rolegroup_metrics_service, build_rolegroup_service},
1718
statefulset::{self, build_rolegroup_statefulset},
@@ -35,6 +36,9 @@ pub enum Error {
3536
source: statefulset::Error,
3637
role_group: RoleGroupName,
3738
},
39+
40+
#[snafu(display("failed to build discovery ConfigMap"))]
41+
Discovery { source: discovery::Error },
3842
}
3943

4044
/// Builds every Kubernetes resource for the given validated cluster.
@@ -44,9 +48,6 @@ pub enum Error {
4448
/// failures only. `cluster_info` is static cluster metadata (not a client call), and
4549
/// `service_account_name` is the name of the RBAC `ServiceAccount` the role-group Pods run under
4650
/// (RBAC resources are built and applied separately, in the reconcile step).
47-
///
48-
/// The role-level discovery `ConfigMap` is applied separately in the reconcile step and is not
49-
/// part of this bundle.
5051
pub fn build(
5152
cluster: &ValidatedCluster,
5253
cluster_info: &KubernetesClusterInfo,
@@ -96,6 +97,10 @@ pub fn build(
9697
}
9798
}
9899

100+
// The role-level discovery ConfigMap advertises the cluster's connection information; it is
101+
// deterministic (derived only from the validated cluster and static cluster info).
102+
config_maps.push(build_discovery_config_map(cluster, cluster_info).context(DiscoverySnafu)?);
103+
99104
Ok(KubernetesResources {
100105
stateful_sets,
101106
services,

rust/operator-binary/src/hbase_controller.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ use stackable_operator::{
2929
use strum::{EnumDiscriminants, IntoStaticStr};
3030

3131
use crate::{
32-
controller::{
33-
build::{self, resource::discovery::build_discovery_config_map},
34-
controller_name, operator_name, product_name,
35-
},
32+
controller::{build, controller_name, operator_name, product_name},
3633
crd::{APP_NAME, HbaseClusterStatus, OPERATOR_NAME, v1alpha1},
3734
};
3835

@@ -75,16 +72,6 @@ pub enum Error {
7572
source: stackable_operator::cluster_resources::Error,
7673
},
7774

78-
#[snafu(display("failed to build discovery configmap"))]
79-
BuildDiscoveryConfigMap {
80-
source: crate::controller::build::resource::discovery::Error,
81-
},
82-
83-
#[snafu(display("failed to apply discovery configmap"))]
84-
ApplyDiscoveryConfigMap {
85-
source: stackable_operator::cluster_resources::Error,
86-
},
87-
8875
#[snafu(display("failed to update status"))]
8976
ApplyStatus {
9077
source: stackable_operator::client::Error,
@@ -210,16 +197,6 @@ pub async fn reconcile_hbase(
210197
);
211198
}
212199

213-
// Discovery CM will fail to build until the rest of the cluster has been deployed, so do it last
214-
// so that failure won't inhibit the rest of the cluster from booting up.
215-
let discovery_cm =
216-
build_discovery_config_map(&validated_cluster, &client.kubernetes_cluster_info)
217-
.context(BuildDiscoveryConfigMapSnafu)?;
218-
cluster_resources
219-
.add(client, discovery_cm)
220-
.await
221-
.context(ApplyDiscoveryConfigMapSnafu)?;
222-
223200
let cluster_operation_cond_builder =
224201
ClusterOperationsConditionBuilder::new(&hbase.spec.cluster_operation);
225202

0 commit comments

Comments
 (0)