Skip to content

Commit 37dcb30

Browse files
committed
refactor: pass ServiceAccount name to StatefulSet builder
1 parent c06e9a4 commit 37dcb30

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ use stackable_operator::{
1515
DeepMerge,
1616
api::{
1717
apps::v1::{StatefulSet, StatefulSetSpec},
18-
core::v1::{
19-
ConfigMapVolumeSource, ContainerPort, Probe, ServiceAccount, TCPSocketAction,
20-
Volume,
21-
},
18+
core::v1::{ConfigMapVolumeSource, ContainerPort, Probe, TCPSocketAction, Volume},
2219
},
2320
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
2421
},
25-
kube::ResourceExt,
2622
product_logging,
2723
v2::{
2824
builder::pod::container::{EnvVarName, EnvVarSet, new_container_builder},
@@ -110,7 +106,7 @@ pub fn build_rolegroup_statefulset(
110106
hbase_role: &HbaseRole,
111107
role_group_name: &RoleGroupName,
112108
validated_rg_config: &HbaseRoleGroupConfig,
113-
service_account: &ServiceAccount,
109+
service_account_name: &str,
114110
) -> Result<StatefulSet> {
115111
let resolved_product_image = &cluster.image;
116112
let merged_config = &validated_rg_config.config.config;
@@ -243,7 +239,7 @@ pub fn build_rolegroup_statefulset(
243239
)),
244240
)
245241
.context(AddVolumeSnafu)?
246-
.service_account_name(service_account.name_any())
242+
.service_account_name(service_account_name)
247243
.security_context(PodSecurityContextBuilder::new().fs_group(1000).build());
248244

249245
// The HBase container's log config ConfigMap: either the operator-generated one (the

rust/operator-binary/src/hbase_controller.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use stackable_operator::{
1313
cluster_resources::ClusterResourceApplyStrategy,
1414
commons::rbac::build_rbac_resources,
1515
kube::{
16+
ResourceExt,
1617
core::{DeserializeGuard, error_boundary},
1718
runtime::controller::Action,
1819
},
@@ -199,6 +200,10 @@ pub async fn reconcile_hbase(
199200
.await
200201
.context(ApplyRoleBindingSnafu)?;
201202

203+
// The ServiceAccount name is deterministic on the built object, so the build step does not
204+
// depend on the applied ServiceAccount.
205+
let service_account_name = rbac_sa.name_any();
206+
202207
let mut ss_cond_builder = StatefulSetConditionBuilder::default();
203208

204209
for (hbase_role, role_group_configs) in &validated_cluster.role_group_configs {
@@ -221,7 +226,7 @@ pub async fn reconcile_hbase(
221226
hbase_role,
222227
role_group_name,
223228
validated_rg_config,
224-
&rbac_sa,
229+
&service_account_name,
225230
)
226231
.with_context(|_| BuildRoleGroupStatefulSetSnafu {
227232
role_group: role_group_name.clone(),

0 commit comments

Comments
 (0)