Skip to content

Commit

Permalink
Fix shard weight. Now we can set it to zero (#1192)
Browse files Browse the repository at this point in the history
* Shard weight can be set to zero

(cherry picked from commit 5033f9e)
  • Loading branch information
maxistua authored and sunsingerus committed Nov 29, 2023
1 parent 8535771 commit ad3d500
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/clickhouse.altinity.com/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ type ChiTemplateNames struct {
// TODO unify with ChiReplica based on HostsSet
type ChiShard struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Weight int `json:"weight,omitempty" yaml:"weight,omitempty"`
Weight *int `json:"weight,omitempty" yaml:"weight,omitempty"`
InternalReplication *StringBool `json:"internalReplication,omitempty" yaml:"internalReplication,omitempty"`
Settings *Settings `json:"settings,omitempty" yaml:"settings,omitempty"`
Files *Settings `json:"files,omitempty" yaml:"files,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/ch_config_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ func (c *ClickHouseConfigGenerator) GetRemoteServers(options *RemoteServersGener
util.Iline(b, 16, "<internal_replication>%s</internal_replication>", shard.InternalReplication)

// <weight>X</weight>
if shard.Weight > 0 {
util.Iline(b, 16, "<weight>%d</weight>", shard.Weight)
if shard.Weight != nil && *shard.Weight >= 0 {
util.Iline(b, 16, "<weight>%d</weight>", *shard.Weight)
}

shard.WalkHosts(func(host *chiv1.ChiHost) error {
Expand Down

0 comments on commit ad3d500

Please sign in to comment.