Skip to content

Commit ea11584

Browse files
Merge pull request #617 from stackabletech/update-release-branch
Update release branch
2 parents ffae639 + 750a156 commit ea11584

File tree

11 files changed

+90
-55
lines changed

11 files changed

+90
-55
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Fixed
8+
9+
- BREAKING: Use distinct ServiceAccounts for the Stacklets, so that multiple Stacklets can be
10+
deployed in one namespace. Existing Stacklets will use the newly created ServiceAccounts after
11+
restart ([#616]).
12+
13+
[#616]: https://github.com/stackabletech/hdfs-operator/pull/616
14+
715
## [24.11.0] - 2024-11-18
816

917
### Added

Cargo.lock

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

Cargo.nix

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ serde = { version = "1.0", features = ["derive"] }
2121
serde_json = "1.0"
2222
serde_yaml = "0.9"
2323
snafu = "0.8"
24-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.80.0" }
24+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.82.0" }
2525
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
2626
strum = { version = "0.26", features = ["derive"] }
2727
tokio = { version = "1.40", features = ["full"] }
2828
tracing = "0.1"
2929
tracing-futures = { version = "0.2", features = ["futures-03"] }
3030

31-
[patch."https://github.com/stackabletech/operator-rs.git"]
31+
#[patch."https://github.com/stackabletech/operator-rs.git"]
3232
#stackable-operator = { path = "../operator-rs/crates/stackable-operator" }
3333
#stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ SHELL=/usr/bin/env bash -euo pipefail
2929
render-readme:
3030
scripts/render_readme.sh
3131

32+
render-docs:
33+
scripts/docs_templating.sh
34+
3235
## Docker related targets
3336
docker-build:
3437
docker build --force-rm --build-arg VERSION=${VERSION} -t "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:${VERSION}-${ARCH}" -f docker/Dockerfile .

crate-hashes.json

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

docs/modules/hdfs/examples/getting_started/getting_started.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@
22
set -euo pipefail
33

44
# DO NOT EDIT THE SCRIPT
5-
# Instead, update the j2 template, and regenerate it for dev:
6-
# cat <<EOF | jinja2 --format yaml getting_started.sh.j2 -o getting_started.sh
7-
# helm:
8-
# repo_name: stackable-dev
9-
# repo_url: https://repo.stackable.tech/repository/helm-dev/
10-
# versions:
11-
# commons: 0.0.0-dev
12-
# hdfs: 0.0.0-dev
13-
# listener: 0.0.0-dev
14-
# secret: 0.0.0-dev
15-
# zookeeper: 0.0.0-dev
16-
# EOF
5+
# Instead, update the j2 template, and regenerate it for dev with `make render-docs`.
176

187
# This script contains all the code snippets from the guide, as well as some assert tests
198
# to test if the instructions in the guide work. The user *could* use it, but it is intended

docs/modules/hdfs/examples/getting_started/getting_started.sh.j2

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@
22
set -euo pipefail
33

44
# DO NOT EDIT THE SCRIPT
5-
# Instead, update the j2 template, and regenerate it for dev:
6-
# cat <<EOF | jinja2 --format yaml getting_started.sh.j2 -o getting_started.sh
7-
# helm:
8-
# repo_name: stackable-dev
9-
# repo_url: https://repo.stackable.tech/repository/helm-dev/
10-
# versions:
11-
# commons: 0.0.0-dev
12-
# hdfs: 0.0.0-dev
13-
# listener: 0.0.0-dev
14-
# secret: 0.0.0-dev
15-
# zookeeper: 0.0.0-dev
16-
# EOF
5+
# Instead, update the j2 template, and regenerate it for dev with `make render-docs`.
176

187
# This script contains all the code snippets from the guide, as well as some assert tests
198
# to test if the instructions in the guide work. The user *could* use it, but it is intended

docs/modules/hdfs/examples/getting_started/hdfs.yaml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ spec:
1111
dfsReplication: 1
1212
nameNodes:
1313
config:
14-
listenerClass: external-stable
14+
listenerClass: external-stable # This exposes your Stacklet outside of Kubernetes. Remove this configuration if this is not desired
1515
roleGroups:
1616
default:
1717
replicas: 2
1818
dataNodes:
1919
config:
20-
listenerClass: external-unstable
20+
listenerClass: external-unstable # This exposes your Stacklet outside of Kubernetes. Remove this configuration if this is not desired
2121
roleGroups:
2222
default:
2323
replicas: 1

rust/operator-binary/src/hdfs_clusterrolebinding_nodes_controller.rs

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ use stackable_hdfs_crd::{
33
constants::{APP_NAME, FIELD_MANAGER_SCOPE},
44
HdfsCluster,
55
};
6+
use stackable_operator::kube::ResourceExt;
67
use stackable_operator::{
7-
commons::rbac::service_account_name,
8+
commons::rbac::build_rbac_resources,
89
k8s_openapi::api::rbac::v1::{ClusterRoleBinding, Subject},
910
kube::{
1011
api::{Patch, PatchParams},
@@ -15,6 +16,7 @@ use stackable_operator::{
1516
},
1617
Api, Client,
1718
},
19+
kvp::Labels,
1820
};
1921
use tracing::{error, info};
2022

@@ -41,18 +43,62 @@ pub async fn reconcile(
4143
)
4244
}
4345
}
46+
4447
// Build a list of SubjectRef objects for all deployed HdfsClusters.
4548
// To do this we only need the metadata for that, as we only really
4649
// need name and namespace of the objects
4750
let subjects: Vec<Subject> = store
4851
.state()
4952
.into_iter()
50-
.map(|object| object.metadata.clone())
51-
.map(|meta| Subject {
52-
kind: "ServiceAccount".to_string(),
53-
name: service_account_name(APP_NAME),
54-
namespace: meta.namespace.clone(),
55-
..Subject::default()
53+
.filter_map(|object| {
54+
// The call to 'build_rbac_resources' can fail, so we
55+
// use filter_map here, log an error for any failures and keep
56+
// going with all the non-broken elements
57+
// Usually we'd rather opt for failing completely here, but in this specific instance
58+
// this could mean that one broken cluster somewhere could impact other working clusters
59+
// within the namespace, so we opted for doing everything we can here, instead of failing
60+
// completely.
61+
match build_rbac_resources(&*object, APP_NAME, Labels::default()) {
62+
Ok((service_account, _role_binding)) => {
63+
Some((object.metadata.clone(), service_account.name_any()))
64+
}
65+
Err(e) => {
66+
error!(
67+
?object,
68+
error = &e as &dyn std::error::Error,
69+
"Failed to build serviceAccount name for hdfs cluster"
70+
);
71+
None
72+
}
73+
}
74+
})
75+
.flat_map(|(meta, sa_name)| {
76+
let mut result = vec![
77+
Subject {
78+
kind: "ServiceAccount".to_string(),
79+
name: sa_name,
80+
namespace: meta.namespace.clone(),
81+
..Subject::default()
82+
},
83+
// This extra Serviceaccount is being written for legacy/compatibility purposes
84+
// to ensure that running clusters don't lose access to anything during an upgrade
85+
// of the Stackable operators, this code can be removed in later releases
86+
// The value is hardcoded here, as we have removed access to the private fns that
87+
// would have built it, since this is a known target though, and will be removed soon
88+
// this should not be an issue.
89+
Subject {
90+
kind: "ServiceAccount".to_string(),
91+
name: "hdfs-serviceaccount".to_string(),
92+
namespace: meta.namespace.clone(),
93+
..Subject::default()
94+
},
95+
];
96+
// If a cluster is called hdfs this would result in the same subject
97+
// being written twicex.
98+
// Since we know this vec only contains two elements we can use dedup for
99+
// simply removing this duplicate.
100+
result.dedup();
101+
result
56102
})
57103
.collect();
58104

rust/operator-binary/src/hdfs_controller.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use product_config::{
99
ProductConfigManager,
1010
};
1111
use snafu::{OptionExt, ResultExt, Snafu};
12+
use stackable_operator::k8s_openapi::api::core::v1::ServiceAccount;
1213
use stackable_operator::{
1314
builder::{
1415
configmap::ConfigMapBuilder,
@@ -17,10 +18,7 @@ use stackable_operator::{
1718
},
1819
client::Client,
1920
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
20-
commons::{
21-
product_image_selection::ResolvedProductImage,
22-
rbac::{build_rbac_resources, service_account_name},
23-
},
21+
commons::{product_image_selection::ResolvedProductImage, rbac::build_rbac_resources},
2422
iter::reverse_if,
2523
k8s_openapi::{
2624
api::{
@@ -326,7 +324,7 @@ pub async fn reconcile_hdfs(
326324
.context(BuildRbacResourcesSnafu)?;
327325

328326
cluster_resources
329-
.add(client, rbac_sa)
327+
.add(client, rbac_sa.clone())
330328
.await
331329
.context(ApplyServiceAccountSnafu)?;
332330
cluster_resources
@@ -434,6 +432,7 @@ pub async fn reconcile_hdfs(
434432
env_overrides,
435433
&merged_config,
436434
&namenode_podrefs,
435+
&rbac_sa,
437436
)?;
438437

439438
let rg_service_name = rg_service.name_any();
@@ -818,6 +817,7 @@ fn rolegroup_statefulset(
818817
env_overrides: Option<&BTreeMap<String, String>>,
819818
merged_config: &AnyNodeConfig,
820819
namenode_podrefs: &[HdfsPodRef],
820+
service_account: &ServiceAccount,
821821
) -> HdfsOperatorResult<StatefulSet> {
822822
tracing::info!("Setting up StatefulSet for {:?}", rolegroup_ref);
823823

@@ -837,7 +837,7 @@ fn rolegroup_statefulset(
837837
pb.metadata(pb_metadata)
838838
.image_pull_secrets_from_product_image(resolved_product_image)
839839
.affinity(&merged_config.affinity)
840-
.service_account_name(service_account_name(APP_NAME))
840+
.service_account_name(service_account.name_any())
841841
.security_context(
842842
PodSecurityContextBuilder::new()
843843
.run_as_user(HDFS_UID)

0 commit comments

Comments
 (0)