Skip to content

Commit fb0a5fd

Browse files
authored
Don't handle buffer pool watermark during warm reboot reconciling (#1987)
- What I did Don't handle buffer pool watermark during warm reboot reconciling - Why I did it This is to fix the community issue sonic-net/sonic-sairedis#862 and #8722 - How I verified it Perform a warm reboot. Check whether buffer pool watermark handling is skipped during reconciling and handled after it. other watermark handling is handled during reconciling as it was before. Details if related The warm reboot flow is like this: System starts. Orchagent fetches the items from database stored before warm reboot and pushes them into m_toSync of all orchagents. This is done by bake, which can be overridden by sub orchagent. All sub orchagents handle the items in m_toSync. At this point, any notification from redis-db is blocked. Warm reboot converges. Orchagent starts to handle notifications from redis-db. The fix is like this: in FlexCounterOrch::bake. the buffer pool watermark handling is skipped. Signed-off-by: Stephen Sun <[email protected]>
1 parent 16d4bcd commit fb0a5fd

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

orchagent/flexcounterorch.cpp

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <unordered_map>
2-
#include "flexcounterorch.h"
32
#include "portsorch.h"
43
#include "fabricportsorch.h"
54
#include "select.h"
@@ -49,6 +48,7 @@ unordered_map<string, string> flexCounterGroupMap =
4948

5049
FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector<string> &tableNames):
5150
Orch(db, tableNames),
51+
m_flexCounterConfigTable(db, CFG_FLEX_COUNTER_TABLE_NAME),
5252
m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)),
5353
m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE))
5454
{
@@ -188,3 +188,45 @@ bool FlexCounterOrch::getPortBufferDropCountersState() const
188188
{
189189
return m_port_buffer_drop_counter_enabled;
190190
}
191+
192+
bool FlexCounterOrch::bake()
193+
{
194+
/*
195+
* bake is called during warmreboot reconciling procedure.
196+
* By default, it should fetch items from the tables the sub agents listen to,
197+
* and then push them into m_toSync of each sub agent.
198+
* The motivation is to make sub agents handle the saved entries first and then handle the upcoming entries.
199+
*/
200+
201+
std::deque<KeyOpFieldsValuesTuple> entries;
202+
vector<string> keys;
203+
m_flexCounterConfigTable.getKeys(keys);
204+
for (const auto &key: keys)
205+
{
206+
if (!flexCounterGroupMap.count(key))
207+
{
208+
SWSS_LOG_NOTICE("FlexCounterOrch: Invalid flex counter group intput %s is skipped during reconciling", key.c_str());
209+
continue;
210+
}
211+
212+
if (key == BUFFER_POOL_WATERMARK_KEY)
213+
{
214+
SWSS_LOG_NOTICE("FlexCounterOrch: Do not handle any FLEX_COUNTER table for %s update during reconciling",
215+
BUFFER_POOL_WATERMARK_KEY);
216+
continue;
217+
}
218+
219+
KeyOpFieldsValuesTuple kco;
220+
221+
kfvKey(kco) = key;
222+
kfvOp(kco) = SET_COMMAND;
223+
224+
if (!m_flexCounterConfigTable.get(key, kfvFieldsValues(kco)))
225+
{
226+
continue;
227+
}
228+
entries.push_back(kco);
229+
}
230+
Consumer* consumer = dynamic_cast<Consumer *>(getExecutor(CFG_FLEX_COUNTER_TABLE_NAME));
231+
return consumer->addToSync(entries);
232+
}

orchagent/flexcounterorch.h

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "orch.h"
55
#include "port.h"
66
#include "producertable.h"
7+
#include "table.h"
78

89
extern "C" {
910
#include "sai.h"
@@ -17,12 +18,14 @@ class FlexCounterOrch: public Orch
1718
virtual ~FlexCounterOrch(void);
1819
bool getPortCountersState() const;
1920
bool getPortBufferDropCountersState() const;
21+
bool bake() override;
2022

2123
private:
2224
std::shared_ptr<swss::DBConnector> m_flexCounterDb = nullptr;
2325
std::shared_ptr<swss::ProducerTable> m_flexCounterGroupTable = nullptr;
2426
bool m_port_counter_enabled = false;
2527
bool m_port_buffer_drop_counter_enabled = false;
28+
Table m_flexCounterConfigTable;
2629
};
2730

2831
#endif

0 commit comments

Comments
 (0)