From 56435329903dd24c728e2dbfce43c8a132fb6a67 Mon Sep 17 00:00:00 2001 From: shlomibitton <60430976+shlomibitton@users.noreply.github.com> Date: Thu, 2 Sep 2021 07:15:36 +0300 Subject: [PATCH] [Flex Counters] Delay flex counters even if tables are present in the DB (#1877) **What I did** Check if delay indicator flag is exist and 'true', if it does, skip the counter enablement. **Why I did it** Currently if flex counters tables are present in config DB the delay mechanism will not take place. This change is to make sure the delay will take place even if the tables are present in the DB. **How I verified it** Observer counters are created after enable_counters script is called. **Details if related** --- orchagent/flexcounterorch.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/orchagent/flexcounterorch.cpp b/orchagent/flexcounterorch.cpp index 41f024c639fd..51c9c9325a65 100644 --- a/orchagent/flexcounterorch.cpp +++ b/orchagent/flexcounterorch.cpp @@ -86,6 +86,12 @@ void FlexCounterOrch::doTask(Consumer &consumer) if (op == SET_COMMAND) { + auto it = std::find(std::begin(data), std::end(data), FieldValueTuple(FLEX_COUNTER_DELAY_STATUS_FIELD, "true")); + + if (it != data.end()) + { + continue; + } for (auto valuePair:data) { const auto &field = fvField(valuePair); @@ -144,6 +150,12 @@ void FlexCounterOrch::doTask(Consumer &consumer) fieldValues.emplace_back(FLEX_COUNTER_STATUS_FIELD, value); m_flexCounterGroupTable->set(flexCounterGroupMap[key], fieldValues); } + else if(field == FLEX_COUNTER_DELAY_STATUS_FIELD) + { + // This field is ignored since it is being used before getting into this loop. + // If it is exist and the value is 'true' we need to skip the iteration in order to delay the counter creation. + // The field will clear out and counter will be created when enable_counters script is called. + } else { SWSS_LOG_NOTICE("Unsupported field %s", field.c_str());