From cca1dc849f87dacd4ce965ac32aa5d97769d8a1d Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Thu, 5 Oct 2023 15:41:31 +0200 Subject: [PATCH] fix: Don't default roleGroup replicas to zero when not specified (#402) * fix: Don't default roleGroup replicas to zero when not specified * changelog --- CHANGELOG.md | 5 +++++ rust/crd/src/lib.rs | 14 ++++---------- rust/operator/src/hdfs_controller.rs | 4 +++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c118c9c8..dca3e166 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.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 diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 22e3e8f1..a4ed3893 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 39a19c90..b1c80a87 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,