Skip to content

Commit 0f209c8

Browse files
committed
chore: adapt to optional replicas
1 parent fdbeb26 commit 0f209c8

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

rust/operator-binary/src/controller/build/resource/statefulset.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ pub fn build_rolegroup_statefulset(
360360
.build(),
361361
spec: Some(StatefulSetSpec {
362362
pod_management_policy: Some("Parallel".to_string()),
363-
replicas: Some(i32::from(rg.replicas)),
363+
// Leave `replicas` unset when the role group does not specify a count, so a
364+
// HorizontalPodAutoscaler can own the replica count without the operator fighting it.
365+
replicas: rg.replicas.map(i32::from),
364366
selector: LabelSelector {
365367
match_labels: Some(cluster.role_group_selector(role, role_group_name).into()),
366368
..LabelSelector::default()

rust/operator-binary/src/crd/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ impl v1alpha1::DruidCluster {
514514
groups.insert(
515515
role_group_name,
516516
DruidRoleGroupConfig {
517-
replicas: validated.replicas.unwrap_or(1),
517+
replicas: validated.replicas,
518518
config: common,
519519
config_overrides: validated.config.config_overrides,
520520
env_overrides,
@@ -668,9 +668,9 @@ fn validate_logging(
668668
/// `product_specific_common_config`; the rendered per-file configs (runtime.properties /
669669
/// security.properties / jvm.config) are produced later, in the config-map build step.
670670
///
671-
/// The StatefulSet replicas come from [`RoleGroupConfig::replicas`] (defaulted to 1 during the
672-
/// merge), mirroring the hive-operator. Upstream `replicas` should be made optional again so an
673-
/// unspecified count can stay HPA-friendly.
671+
/// The StatefulSet replicas come from [`RoleGroupConfig::replicas`], which is optional: an
672+
/// unspecified count is passed through as `None` to the StatefulSet so a HorizontalPodAutoscaler
673+
/// can own the replica count.
674674
pub type DruidRoleGroupConfig =
675675
RoleGroupConfig<ValidatedDruidConfig, JavaCommonConfig, DruidConfigOverrides>;
676676

0 commit comments

Comments
 (0)