From 814f6594f98f6b2e70da6acb50eccec3ad4077fb Mon Sep 17 00:00:00 2001 From: Stephen Sun Date: Wed, 17 Nov 2021 23:57:22 +0000 Subject: [PATCH] Check whether flex counter has been configured before clear counter on removing a pool Signed-off-by: Stephen Sun --- orchagent/bufferorch.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 0aa593846a..6f60d15c3e 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -212,8 +212,11 @@ bool BufferOrch::isPortReady(const std::string& port_name) const void BufferOrch::clearBufferPoolWatermarkCounterIdList(const sai_object_id_t object_id) { - string key = BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP ":" + sai_serialize_object_id(object_id); - m_flexCounterTable->del(key); + if (m_isBufferPoolWatermarkCounterIdListGenerated) + { + string key = BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP ":" + sai_serialize_object_id(object_id); + m_flexCounterTable->del(key); + } } void BufferOrch::generateBufferPoolWatermarkCounterIdList(void)