Skip to content

Commit

Permalink
[FC] process FC after apply view
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
  • Loading branch information
stepanblyschak committed Oct 11, 2024
1 parent 766e755 commit ff1ac3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 47 deletions.
47 changes: 2 additions & 45 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ void FlexCounterOrch::doTask(Consumer &consumer)

if (op == SET_COMMAND)
{
auto itDelay = std::find(std::begin(data), std::end(data), FieldValueTuple(FLEX_COUNTER_DELAY_STATUS_FIELD, "true"));
string poll_interval;

if (itDelay != data.end())
{
consumer.m_toSync.erase(it++);
continue;
}
for (auto valuePair:data)
{
const auto &field = fvField(valuePair);
Expand Down Expand Up @@ -237,12 +229,6 @@ void FlexCounterOrch::doTask(Consumer &consumer)
}
}
}
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());
Expand Down Expand Up @@ -291,39 +277,10 @@ bool FlexCounterOrch::bake()
* By default, it should fetch items from the tables the sub agents listen to,
* and then push them into m_toSync of each sub agent.
* The motivation is to make sub agents handle the saved entries first and then handle the upcoming entries.
* The FCs are not data plane configuration required during reconciling process, hence don't do anything in bake.
*/

std::deque<KeyOpFieldsValuesTuple> entries;
vector<string> keys;
m_flexCounterConfigTable.getKeys(keys);
for (const auto &key: keys)
{
if (!flexCounterGroupMap.count(key))
{
SWSS_LOG_NOTICE("FlexCounterOrch: Invalid flex counter group intput %s is skipped during reconciling", key.c_str());
continue;
}

if (key == BUFFER_POOL_WATERMARK_KEY)
{
SWSS_LOG_NOTICE("FlexCounterOrch: Do not handle any FLEX_COUNTER table for %s update during reconciling",
BUFFER_POOL_WATERMARK_KEY);
continue;
}

KeyOpFieldsValuesTuple kco;

kfvKey(kco) = key;
kfvOp(kco) = SET_COMMAND;

if (!m_flexCounterConfigTable.get(key, kfvFieldsValues(kco)))
{
continue;
}
entries.push_back(kco);
}
Consumer* consumer = dynamic_cast<Consumer *>(getExecutor(CFG_FLEX_COUNTER_TABLE_NAME));
return consumer->addToSync(entries);
return true;
}

static bool isCreateOnlyConfigDbBuffers(Table& deviceMetadataConfigTable)
Expand Down
11 changes: 9 additions & 2 deletions tests/mock_tests/flexcounter_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,7 @@ namespace flexcounter_test
ASSERT_TRUE(gPortsOrch->allPortsReady());

// Enable and check counters
const std::vector<FieldValueTuple> values({ {FLEX_COUNTER_DELAY_STATUS_FIELD, "false"},
{FLEX_COUNTER_STATUS_FIELD, "enable"} });
const std::vector<FieldValueTuple> values({ {FLEX_COUNTER_STATUS_FIELD, "enable"} });
flexCounterCfg.set("PG_WATERMARK", values);
flexCounterCfg.set("QUEUE_WATERMARK", values);
flexCounterCfg.set("QUEUE", values);
Expand Down Expand Up @@ -831,6 +830,14 @@ namespace flexcounter_test
entries.clear();
static_cast<Orch *>(gBufferOrch)->doTask();
ASSERT_TRUE(checkFlexCounter(BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP, pool_oid));

// Warm/fast-boot case - no FC processing done before APPLY_VIEW
std::vector<std::string> ts;

gDirectory.get<FlexCounterOrch*>()->bake();
gDirectory.get<FlexCounterOrch*>()->dumpPendingTasks(ts);

ASSERT_TRUE(ts.empty());
}

INSTANTIATE_TEST_CASE_P(
Expand Down

0 comments on commit ff1ac3b

Please sign in to comment.