Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set weights only on vshard storage instances #225

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions pkg/topology/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,28 @@ func (r *CommonCartridgeTopology) SetWeight(ctx context.Context, leader *v1.Pod,
local uuid, weight = ...

local replicaset = cartridge.admin_get_replicasets(uuid)[1]
local actualWight = 0

if replicaset ~= nil and replicaset.weight ~= nil and actualWight ~= box.NULL then
actualWight = replicaset.weight
--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
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}
Expand Down Expand Up @@ -223,11 +238,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
`

Expand Down Expand Up @@ -324,7 +339,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
Expand Down