Skip to content

Commit 8ee6472

Browse files
committed
chore: use service account name instead of resource
1 parent c2e5bc7 commit 8ee6472

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use stackable_operator::{
1010
cluster_resources::ClusterResourceApplyStrategy,
1111
commons::rbac::build_rbac_resources,
1212
kube::{
13+
ResourceExt,
1314
core::{DeserializeGuard, error_boundary},
1415
runtime::controller::Action,
1516
},
@@ -213,9 +214,13 @@ pub async fn reconcile_druid(
213214
.context(GetRequiredLabelsSnafu)?,
214215
)
215216
.context(BuildRbacResourcesSnafu)?;
217+
218+
// The ServiceAccount name is deterministic on the built object, so the StatefulSet builder only
219+
// needs the name and does not depend on the applied ServiceAccount.
220+
let service_account_name = rbac_sa.name_any();
221+
216222
cluster_resources
217-
// We clone rbac_sa because we need to reuse it below
218-
.add(client, rbac_sa.clone())
223+
.add(client, rbac_sa)
219224
.await
220225
.context(ApplyServiceAccountSnafu)?;
221226
cluster_resources
@@ -250,7 +255,7 @@ pub async fn reconcile_druid(
250255
druid_role,
251256
rolegroup_name,
252257
rg,
253-
&rbac_sa,
258+
&service_account_name,
254259
)
255260
.context(BuildRoleGroupStatefulSetSnafu)?;
256261

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ use stackable_operator::{
1616
DeepMerge,
1717
api::{
1818
apps::v1::{StatefulSet, StatefulSetSpec},
19-
core::v1::{EnvVar, PersistentVolumeClaim, ServiceAccount},
19+
core::v1::{EnvVar, PersistentVolumeClaim},
2020
},
2121
apimachinery::pkg::apis::meta::v1::LabelSelector,
2222
},
23-
kube::ResourceExt,
2423
product_logging,
2524
v2::{
2625
builder::pod::container::{EnvVarSet, new_container_builder},
@@ -114,7 +113,7 @@ pub fn build_rolegroup_statefulset(
114113
role: &DruidRole,
115114
role_group_name: &RoleGroupName,
116115
rg: &DruidRoleGroupConfig,
117-
service_account: &ServiceAccount,
116+
service_account_name: &str,
118117
) -> Result<StatefulSet> {
119118
let merged_rolegroup_config = &rg.config;
120119
let resource_names = cluster.resource_names(role, role_group_name);
@@ -322,7 +321,7 @@ pub fn build_rolegroup_statefulset(
322321
.add_init_container(cb_prepare.build())
323322
.add_container(cb_druid.build())
324323
.metadata(metadata)
325-
.service_account_name(service_account.name_any())
324+
.service_account_name(service_account_name)
326325
.security_context(PodSecurityContextBuilder::new().fs_group(1000).build());
327326

328327
// The Vector agent reads the static `vector.yaml` (added to the rolegroup ConfigMap) from the

0 commit comments

Comments
 (0)