From a4be4bf80f4b66bf03051e383a59b2fb32a33264 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 29 Sep 2023 09:38:21 +0200 Subject: [PATCH 1/2] fix: Don't default roleGroup replicas to zero when not specified --- rust/crd/src/lib.rs | 14 ++++---------- rust/operator/src/hdfs_controller.rs | 4 +++- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 0efe88d5..641d739f 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -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 { 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), } } diff --git a/rust/operator/src/hdfs_controller.rs b/rust/operator/src/hdfs_controller.rs index 203f50d0..c8be7027 100644 --- a/rust/operator/src/hdfs_controller.rs +++ b/rust/operator/src/hdfs_controller.rs @@ -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, From 7f1ff5e87d70c2664acf7483bba24a69dba1043b Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 29 Sep 2023 09:39:27 +0200 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 286bd9bc..f5922cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.51.1` ([#381], [#394]). +### 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 ## [23.7.0] - 2023-07-14