Skip to content

Commit b4b9232

Browse files
committed
Make necessary changes to reflect now private fns in op-rs due.
1 parent f7fd64d commit b4b9232

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/operator-binary/src/hdfs_clusterrolebinding_nodes_controller.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use stackable_hdfs_crd::{
44
HdfsCluster,
55
};
66
use stackable_operator::{
7-
commons::rbac::service_account_name,
7+
commons::rbac::build_rbac_resources,
88
k8s_openapi::api::rbac::v1::{ClusterRoleBinding, Subject},
99
kube::{
1010
api::{Patch, PatchParams},
@@ -15,6 +15,7 @@ use stackable_operator::{
1515
},
1616
Api, Client,
1717
},
18+
kvp::Labels,
1819
};
1920
use tracing::{error, info};
2021

@@ -41,16 +42,27 @@ pub async fn reconcile(
4142
)
4243
}
4344
}
45+
4446
// Build a list of SubjectRef objects for all deployed HdfsClusters.
4547
// To do this we only need the metadata for that, as we only really
4648
// need name and namespace of the objects
4749
let subjects: Vec<Subject> = store
4850
.state()
4951
.into_iter()
50-
.map(|object| object.metadata.clone())
51-
.map(|meta| Subject {
52+
.map(|object| {
53+
(
54+
object.metadata.clone(),
55+
build_rbac_resources(&*object, APP_NAME, Labels::default())
56+
.expect("failed to get serviceAccount for object")
57+
.0
58+
.metadata
59+
.name
60+
.unwrap(),
61+
)
62+
})
63+
.map(|(meta, sa_name)| Subject {
5264
kind: "ServiceAccount".to_string(),
53-
name: service_account_name(APP_NAME),
65+
name: sa_name,
5466
namespace: meta.namespace.clone(),
5567
..Subject::default()
5668
})

rust/operator-binary/src/hdfs_controller.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use stackable_operator::{
1919
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
2020
commons::{
2121
product_image_selection::ResolvedProductImage,
22-
rbac::{build_rbac_resources, service_account_name},
22+
rbac::build_rbac_resources,
2323
},
2424
iter::reverse_if,
2525
k8s_openapi::{
@@ -50,6 +50,7 @@ use stackable_operator::{
5050
time::Duration,
5151
utils::cluster_info::KubernetesClusterInfo,
5252
};
53+
use stackable_operator::k8s_openapi::api::core::v1::ServiceAccount;
5354
use strum::{EnumDiscriminants, IntoEnumIterator, IntoStaticStr};
5455

5556
use stackable_hdfs_crd::{
@@ -326,7 +327,8 @@ pub async fn reconcile_hdfs(
326327
.context(BuildRbacResourcesSnafu)?;
327328

328329
cluster_resources
329-
.add(client, rbac_sa)
330+
// We clone here because we need to use rbac_sa further down
331+
.add(client, rbac_sa.clone())
330332
.await
331333
.context(ApplyServiceAccountSnafu)?;
332334
cluster_resources
@@ -434,6 +436,7 @@ pub async fn reconcile_hdfs(
434436
env_overrides,
435437
&merged_config,
436438
&namenode_podrefs,
439+
&rbac_sa
437440
)?;
438441

439442
let rg_service_name = rg_service.name_any();
@@ -818,6 +821,7 @@ fn rolegroup_statefulset(
818821
env_overrides: Option<&BTreeMap<String, String>>,
819822
merged_config: &AnyNodeConfig,
820823
namenode_podrefs: &[HdfsPodRef],
824+
service_account: &ServiceAccount,
821825
) -> HdfsOperatorResult<StatefulSet> {
822826
tracing::info!("Setting up StatefulSet for {:?}", rolegroup_ref);
823827

@@ -837,7 +841,7 @@ fn rolegroup_statefulset(
837841
pb.metadata(pb_metadata)
838842
.image_pull_secrets_from_product_image(resolved_product_image)
839843
.affinity(&merged_config.affinity)
840-
.service_account_name(service_account_name(APP_NAME))
844+
.service_account_name(service_account.name_any())
841845
.security_context(
842846
PodSecurityContextBuilder::new()
843847
.run_as_user(HDFS_UID)

0 commit comments

Comments
 (0)