From f01aefc117d6b81d06c045b0786544fbd455a15d Mon Sep 17 00:00:00 2001 From: Kyle Schochenmaier Date: Wed, 19 Nov 2025 12:34:48 -0600 Subject: [PATCH] in the case where replicas override data/logVolumeClaimTemplates but the shard does not set these the overrides are ignored, prefer the replica settings always as they are more fine grained control points --- .../clickhouse-keeper.altinity.com/v1/type_cluster.go | 8 +++++++- pkg/apis/clickhouse.altinity.com/v1/type_cluster.go | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/apis/clickhouse-keeper.altinity.com/v1/type_cluster.go b/pkg/apis/clickhouse-keeper.altinity.com/v1/type_cluster.go index 301287826..e73e0acf0 100644 --- a/pkg/apis/clickhouse-keeper.altinity.com/v1/type_cluster.go +++ b/pkg/apis/clickhouse-keeper.altinity.com/v1/type_cluster.go @@ -163,7 +163,7 @@ func (cluster *Cluster) isShardExplicitlySpecified() bool { // isReplicaExplicitlySpecified checks whether replica is explicitly specified func (cluster *Cluster) isReplicaExplicitlySpecified() bool { - return cluster.Layout.ReplicasExplicitlySpecified && !cluster.isShardExplicitlySpecified() + return cluster.Layout.ReplicasExplicitlySpecified } // IsShardSpecified checks whether shard is explicitly specified @@ -172,6 +172,12 @@ func (cluster *Cluster) isShardToBeUsedToInheritSettingsFrom() bool { return true } + // When both shards and replicas are explicitly specified, prefer replicas + // since replica-level configuration is more specific than shard-level + if cluster.isShardExplicitlySpecified() && cluster.isReplicaExplicitlySpecified() { + return false + } + return cluster.isShardExplicitlySpecified() } diff --git a/pkg/apis/clickhouse.altinity.com/v1/type_cluster.go b/pkg/apis/clickhouse.altinity.com/v1/type_cluster.go index cebf8a6ec..3f267b65a 100644 --- a/pkg/apis/clickhouse.altinity.com/v1/type_cluster.go +++ b/pkg/apis/clickhouse.altinity.com/v1/type_cluster.go @@ -172,7 +172,7 @@ func (cluster *Cluster) isShardExplicitlySpecified() bool { // isReplicaExplicitlySpecified checks whether replica is explicitly specified func (cluster *Cluster) isReplicaExplicitlySpecified() bool { - return cluster.Layout.ReplicasExplicitlySpecified && !cluster.isShardExplicitlySpecified() + return cluster.Layout.ReplicasExplicitlySpecified } // IsShardSpecified checks whether shard is explicitly specified @@ -181,6 +181,12 @@ func (cluster *Cluster) isShardToBeUsedToInheritSettingsFrom() bool { return true } + // When both shards and replicas are explicitly specified, prefer replicas + // since replica-level configuration is more specific than shard-level + if cluster.isShardExplicitlySpecified() && cluster.isReplicaExplicitlySpecified() { + return false + } + return cluster.isShardExplicitlySpecified() }