Skip to content

Commit

Permalink
fix: Don't default roleGroup replicas to zero when not specified (#402)
Browse files Browse the repository at this point in the history
* fix: Don't default roleGroup replicas to zero when not specified

* changelog
  • Loading branch information
sbernauer authored Oct 5, 2023
1 parent 51fb158 commit cca1dc8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ All notable changes to this project will be documented in this file.
- Let secret-operator handle certificate conversion ([#392]).
- `operator-rs` `0.44.0` -> `0.52.0` ([#381], [#394], [#404]).

### Fixed

- Don't default roleGroup replicas to zero when not specified ([#402]).

[#378]: https://github.com/stackabletech/hdfs-operator/pull/378
[#381]: https://github.com/stackabletech/hdfs-operator/pull/381
[#384]: https://github.com/stackabletech/hdfs-operator/pull/384
[#392]: https://github.com/stackabletech/hdfs-operator/pull/392
[#394]: https://github.com/stackabletech/hdfs-operator/pull/394
[#402]: https://github.com/stackabletech/hdfs-operator/pull/402
[#404]: https://github.com/stackabletech/hdfs-operator/pull/404

## [23.7.0] - 2023-07-14
Expand Down
14 changes: 4 additions & 10 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,23 +377,17 @@ impl HdfsRole {
}

/// Return replicas for a certain rolegroup.
pub fn role_group_replicas(&self, hdfs: &HdfsCluster, role_group: &str) -> i32 {
pub fn role_group_replicas(&self, hdfs: &HdfsCluster, role_group: &str) -> Option<u16> {
match self {
HdfsRole::NameNode => hdfs
.namenode_rolegroup(role_group)
.and_then(|rg| rg.replicas)
.unwrap_or_default()
.into(),
.and_then(|rg| rg.replicas),
HdfsRole::DataNode => hdfs
.datanode_rolegroup(role_group)
.and_then(|rg| rg.replicas)
.unwrap_or_default()
.into(),
.and_then(|rg| rg.replicas),
HdfsRole::JournalNode => hdfs
.journalnode_rolegroup(role_group)
.and_then(|rg| rg.replicas)
.unwrap_or_default()
.into(),
.and_then(|rg| rg.replicas),
}
}

Expand Down
4 changes: 3 additions & 1 deletion rust/operator/src/hdfs_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,9 @@ fn rolegroup_statefulset(
.build(),
spec: Some(StatefulSetSpec {
pod_management_policy: Some("OrderedReady".to_string()),
replicas: Some(role.role_group_replicas(hdfs, &rolegroup_ref.role_group)),
replicas: role
.role_group_replicas(hdfs, &rolegroup_ref.role_group)
.map(i32::from),
selector: LabelSelector {
match_labels: Some(role_group_selector_labels(
hdfs,
Expand Down

0 comments on commit cca1dc8

Please sign in to comment.