From 18ebc5e2d97d23b0664b4983c0fda7df6c57e020 Mon Sep 17 00:00:00 2001 From: yimgzz Date: Fri, 14 Feb 2025 11:28:01 +0300 Subject: [PATCH 1/2] fix typo --- pkg/topology/common.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/topology/common.go b/pkg/topology/common.go index 5cd5109..dfe99b7 100644 --- a/pkg/topology/common.go +++ b/pkg/topology/common.go @@ -102,13 +102,13 @@ func (r *CommonCartridgeTopology) SetWeight(ctx context.Context, leader *v1.Pod, local uuid, weight = ... local replicaset = cartridge.admin_get_replicasets(uuid)[1] - local actualWight = 0 + local actualWeight = 0 - if replicaset ~= nil and replicaset.weight ~= nil and actualWight ~= box.NULL then - actualWight = replicaset.weight + if replicaset ~= nil and replicaset.weight ~= nil and actualWeight ~= box.NULL then + actualWeight = replicaset.weight end - if replicaset == nil or actualWight ~= weight then + if replicaset == nil or actualWeight ~= weight then local topology, err = cartridge.admin_edit_topology({ replicasets = { { uuid = uuid , weight = weight} @@ -223,11 +223,11 @@ func (r *CommonCartridgeTopology) GetRolesHierarchy(ctx context.Context, leader lua := ` local roles = require('cartridge.roles') local hierarchy = {} - + for _, roleName in pairs(roles.get_all_roles()) do hierarchy[roleName] = roles.get_role_dependencies(roleName) end - + return hierarchy ` @@ -324,7 +324,7 @@ func (r *CommonCartridgeTopology) GetCartridgeConfig(ctx context.Context, leader ['vshard_groups.yml'] = true, ['schema.yml'] = true, } - + local ret = {} for section, data in pairs(cfg) do if not blacklist[section] then From e61e581853f8f92a51b71dcd3964b5b3562ec7e5 Mon Sep 17 00:00:00 2001 From: yimgzz Date: Fri, 14 Feb 2025 11:28:47 +0300 Subject: [PATCH 2/2] fix: setting weights only on vshard storages --- pkg/topology/common.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/topology/common.go b/pkg/topology/common.go index dfe99b7..cd70f13 100644 --- a/pkg/topology/common.go +++ b/pkg/topology/common.go @@ -102,6 +102,21 @@ func (r *CommonCartridgeTopology) SetWeight(ctx context.Context, leader *v1.Pod, local uuid, weight = ... local replicaset = cartridge.admin_get_replicasets(uuid)[1] + + --setting weights only for vhsard storages + local isVshardStorage = false + + for _, role in ipairs(replicaset.roles) do + if role == "vshard-storage" then + isVshardStorage = true + break + end + end + + if not isVshardStorage then + return { res=true, err=nil } + end + local actualWeight = 0 if replicaset ~= nil and replicaset.weight ~= nil and actualWeight ~= box.NULL then