Skip to content

Commit fb5195d

Browse files
Felix Hennigfhennig
andcommitted
Fix: node selector (#293)
# Description Parent ticket: stackabletech/issues#300 Co-authored-by: Felix Hennig <fhennig@users.noreply.github.com>
1 parent 307f3f2 commit fb5195d

6 files changed

Lines changed: 49 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
- [BREAKING] Use Product image selection instead of version. `spec.version` has been replaced by `spec.image` ([#282]).
88
- Updated stackable image versions ([#275]).
9-
- `operator-rs` `0.24.0` -> `0.27.1` ([#277]).
9+
- `operator-rs` `0.24.0` -> `0.30.1` ([#277], [#293]).
1010
- Set runAsGroup to 1000 rather than 0 ([#283]).
11+
- Fixed: `selector` in role groups now works. It was not working before ([#293])
1112

1213
[#275]: https://github.com/stackabletech/hbase-operator/pull/275
1314
[#277]: https://github.com/stackabletech/hbase-operator/pull/277
1415
[#282]: https://github.com/stackabletech/hbase-operator/pull/282
1516
[#283]: https://github.com/stackabletech/hbase-operator/pull/283
17+
[#293]: https://github.com/stackabletech/hbase-operator/pull/293
1618

1719
## [0.5.0] - 2022-11-07
1820

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.

rust/crd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version = "0.6.0-nightly"
99
publish = false
1010

1111
[dependencies]
12-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.27.1" }
12+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.30.1" }
1313

1414
serde = "1.0"
1515
serde_json = "1.0"

rust/crd/src/lib.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use stackable_operator::{
1212
k8s_openapi::apimachinery::pkg::api::resource::Quantity,
1313
kube::{runtime::reflector::ObjectRef, CustomResource},
1414
product_config_utils::{ConfigError, Configuration},
15-
role_utils::{Role, RoleGroupRef},
15+
role_utils::{Role, RoleGroup, RoleGroupRef},
1616
schemars::{self, JsonSchema},
1717
};
18-
use std::collections::BTreeMap;
18+
use std::{collections::BTreeMap, str::FromStr};
1919
use strum::{Display, EnumIter, EnumString};
2020

2121
pub const APP_NAME: &str = "hbase";
@@ -47,8 +47,15 @@ pub const JVM_HEAP_FACTOR: f32 = 0.8;
4747

4848
#[derive(Snafu, Debug)]
4949
pub enum Error {
50+
#[snafu(display("the role [{role}] is invalid and does not exist in HBase"))]
51+
InvalidRole {
52+
source: strum::ParseError,
53+
role: String,
54+
},
5055
#[snafu(display("the HBase role [{role}] is missing from spec"))]
5156
MissingHbaseRole { role: String },
57+
#[snafu(display("the HBase role group [{role_group}] is missing from spec"))]
58+
MissingHbaseRoleGroup { role_group: String },
5259
#[snafu(display("fragment validation failure"))]
5360
FragmentValidationFailure { source: ValidationError },
5461
}
@@ -278,6 +285,27 @@ impl HbaseCluster {
278285
}
279286
}
280287

288+
/// Get the RoleGroup struct for the given ref
289+
pub fn get_role_group(
290+
&self,
291+
rolegroup_ref: &RoleGroupRef<HbaseCluster>,
292+
) -> Result<&RoleGroup<HbaseConfig>, Error> {
293+
let role_variant =
294+
HbaseRole::from_str(&rolegroup_ref.role).with_context(|_| InvalidRoleSnafu {
295+
role: rolegroup_ref.role.to_owned(),
296+
})?;
297+
let role = self
298+
.get_role(&role_variant)
299+
.with_context(|| MissingHbaseRoleSnafu {
300+
role: role_variant.to_string(),
301+
})?;
302+
role.role_groups
303+
.get(&rolegroup_ref.role_group)
304+
.with_context(|| MissingHbaseRoleGroupSnafu {
305+
role_group: rolegroup_ref.role_group.to_owned(),
306+
})
307+
}
308+
281309
pub fn root_dir(&self) -> String {
282310
self.spec
283311
.config

rust/operator-binary/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ futures = { version = "0.3", features = ["compat"] }
1616
serde = "1.0"
1717
snafu = "0.7"
1818
stackable-hbase-crd = { path = "../crd" }
19-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.27.1" }
19+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.30.1" }
2020
strum = { version = "0.24", features = ["derive"] }
2121
tokio = { version = "1.23", features = ["macros", "rt-multi-thread"] }
2222
tracing = "0.1"
2323

2424
[build-dependencies]
2525
built = { version = "0.5", features = ["chrono", "git2"] }
2626
stackable-hbase-crd = { path = "../crd" }
27-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.27.1" }
27+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.30.1" }

rust/operator-binary/src/hbase_controller.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ pub enum Error {
151151
source: strum::ParseError,
152152
role: String,
153153
},
154+
#[snafu(display("failed to retrieve Hbase role group: {source}"))]
155+
UnidentifiedHbaseRoleGroup { source: stackable_hbase_crd::Error },
154156
#[snafu(display("failed to resolve and merge resource config for role and role group"))]
155157
FailedToResolveResourceConfig { source: stackable_hbase_crd::Error },
156158
#[snafu(display("invalid java heap config - missing default or value in crd?"))]
@@ -621,6 +623,13 @@ fn build_rolegroup_statefulset(
621623
))
622624
})
623625
.image_pull_secrets_from_product_image(resolved_product_image)
626+
.node_selector_opt(
627+
hbase
628+
.get_role_group(rolegroup_ref)
629+
.context(UnidentifiedHbaseRoleGroupSnafu)?
630+
.selector
631+
.clone(),
632+
)
624633
.add_container(container)
625634
.add_volume(stackable_operator::k8s_openapi::api::core::v1::Volume {
626635
name: "hbase-config".to_string(),

0 commit comments

Comments
 (0)