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

[Dynamic Buffer][Mellanox] Skip PGs in pending deleting set while checking accumulative headroom of a port #2871

Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions cfgmgr/buffer_check_headroom_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,25 @@ local function get_number_of_pgs(keyname)
return size
end

-- Fetch all the pending removing PGs
local pending_remove_pg_keys = redis.call('SMEMBERS', 'BUFFER_PG_TABLE_DEL_SET')
local pending_remove_pg_set = {}
for i = 1, #pending_remove_pg_keys do
pending_remove_pg_set['BUFFER_PG_TABLE:' .. pending_remove_pg_keys[i]] = true
table.insert(debuginfo, 'debug:pending remove entry found: ' .. 'BUFFER_PG_TABLE:' .. pending_remove_pg_keys[i])
end

-- Fetch all the PGs in APPL_DB, and store them into a hash table
-- But skip the items that are in pending_remove_pg_set
local pg_keys = redis.call('KEYS', 'BUFFER_PG_TABLE:' .. port .. ':*')
local all_pgs = {}
for i = 1, #pg_keys do
local profile = redis.call('HGET', pg_keys[i], 'profile')
all_pgs[pg_keys[i]] = profile
if not pending_remove_pg_set[pg_keys[i]] then
local profile = redis.call('HGET', pg_keys[i], 'profile')
all_pgs[pg_keys[i]] = profile
else
table.insert(debuginfo, 'debug:pending remove entry skipped: ' .. pg_keys[i])
end
end

-- Fetch all the pending PGs, and store them into the hash table
Expand Down
13 changes: 13 additions & 0 deletions tests/test_buffer_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,19 @@ def test_bufferPortMaxParameter(self, dvs, testlog):
profile_fvs['xoff'] = '9216'
self.config_db.update_entry('BUFFER_PROFILE', 'test', profile_fvs)
self.app_db.wait_for_field_match('BUFFER_PROFILE_TABLE', 'test', profile_fvs)

# Verify a pending remove PG is not counted into the accumulative headroom
dvs.runcmd("kill -s SIGSTOP {}".format(oa_pid))

self.config_db.delete_entry('BUFFER_PG', 'Ethernet0|3-4')
# Should be added because PG 3-4 has been removed and there are sufficient headroom
self.config_db.update_entry('BUFFER_PG', 'Ethernet0|1', {'profile': 'ingress_lossy_profile'})

# Resume orchagent
dvs.runcmd("kill -s SIGCONT {}".format(oa_pid))

# Check whether BUFFER_PG_TABLE is updated as expected
self.app_db.wait_for_field_match("BUFFER_PG_TABLE", "Ethernet0:1", {"profile": "ingress_lossy_profile"})
finally:
dvs.runcmd("kill -s SIGCONT {}".format(oa_pid))

Expand Down