Skip to content

Commit 8683252

Browse files
committed
[syncd] Transfer not processed objects to temp view
Check issue sonic-net#899 for details.
1 parent 556d100 commit 8683252

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

syncd/ComparisonLogic.cpp

+91-1
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ void ComparisonLogic::compareViews()
122122

123123
applyViewTransition(current, temp);
124124

125+
transferNotProcessed(current, temp);
126+
125127
// TODO have a method to check for not processed objects
126128
// and maybe add them to list on processing attributes
127-
// and move note processed objects to temporay view as well
129+
// and move note processed objects to temporary view as well
128130
// we need to check oid attributes as well
129131

130132
SWSS_LOG_NOTICE("ASIC operations to execute: %zu", current.asicGetOperationsCount());
@@ -1635,6 +1637,21 @@ bool ComparisonLogic::performObjectSetTransition(
16351637
meta->attridname,
16361638
currentAttr->getStrAttrValue().c_str());
16371639

1640+
// don't produce too much noise for queues
1641+
if (currentAttr->getStrAttrId() != "SAI_QUEUE_ATTR_TYPE")
1642+
{
1643+
SWSS_LOG_WARN("current attr is CREATE_ONLY and object is MATCHED: %s transferring %s:%s to temp object",
1644+
currentBestMatch->m_str_object_id.c_str(),
1645+
meta->attridname,
1646+
currentAttr->getStrAttrValue().c_str());
1647+
}
1648+
1649+
std::shared_ptr<SaiAttr> transferedAttr = std::make_shared<SaiAttr>(
1650+
currentAttr->getStrAttrId(),
1651+
currentAttr->getStrAttrValue());
1652+
1653+
temporaryObj->setAttr(transferedAttr);
1654+
16381655
continue;
16391656
}
16401657
}
@@ -2803,6 +2820,79 @@ void ComparisonLogic::createPreMatchMap(
28032820
count);
28042821
}
28052822

2823+
void ComparisonLogic::transferNotProcessed(
2824+
_In_ AsicView& current,
2825+
_In_ AsicView& temp)
2826+
{
2827+
SWSS_LOG_ENTER();
2828+
2829+
SWSS_LOG_NOTICE("calling transferNotProcessed");
2830+
2831+
/*
2832+
* It may happen that after performing view transition, some objects will
2833+
* not be processed. This may happen is scenario where buffer pool is
2834+
* assigned to buffer profile, and then buffer profile is assigned to
2835+
* queue. If OA will query only for oid for that buffer profile, then
2836+
* buffer pool will not be processed. Normally if it would be removed by
2837+
* comparison logic. More on this issue can be found on github:
2838+
* https://github.com/Azure/sonic-sairedis/issues/899
2839+
*
2840+
* So what we will do, we will transfer all not processed objects to
2841+
* temporary view with the same RID and VID. If nothing will happen to them,
2842+
* they will stay there until next warm boot where they will be removed.
2843+
*/
2844+
2845+
/*
2846+
* We need a loop (or recursion) since not processed objects may have oid
2847+
* attributes as well.
2848+
*/
2849+
2850+
while (current.getAllNotProcessedObjects().size())
2851+
{
2852+
SWSS_LOG_WARN("we have %zu not processed objects on current view, moving to temp view", current.getAllNotProcessedObjects().size());
2853+
2854+
for (const auto& obj: current.getAllNotProcessedObjects())
2855+
{
2856+
auto vid = obj->getVid();
2857+
2858+
auto rid = current.m_vidToRid.at(vid);
2859+
2860+
/*
2861+
* We should have only oid objects here, since all non oid objects
2862+
* are leafs in graph and has been removed.
2863+
*/
2864+
2865+
auto tmp = temp.createDummyExistingObject(rid, vid);
2866+
2867+
/*
2868+
* Move both objects to matched state since match oids was already
2869+
* called, and here we created some new objects that should be matched.
2870+
*/
2871+
2872+
current.m_oOids.at(vid)->setObjectStatus(SAI_OBJECT_STATUS_FINAL);
2873+
temp.m_oOids.at(vid)->setObjectStatus(SAI_OBJECT_STATUS_FINAL);
2874+
2875+
SWSS_LOG_WARN("moved %s VID %s RID %s to temporary view, and marked FINAL",
2876+
obj->m_str_object_type.c_str(),
2877+
obj->m_str_object_id.c_str(),
2878+
sai_serialize_object_id(rid).c_str());
2879+
2880+
for (auto& kvp: obj->getAllAttributes())
2881+
{
2882+
auto& sh = kvp.second;
2883+
2884+
auto attr = std::make_shared<SaiAttr>(sh->getStrAttrId(), sh->getStrAttrValue());
2885+
2886+
tmp->setAttr(attr);
2887+
2888+
SWSS_LOG_WARN(" * with attr: %s: %s",
2889+
sh->getStrAttrId().c_str(),
2890+
sh->getStrAttrValue().c_str());
2891+
}
2892+
2893+
}
2894+
}
2895+
}
28062896

28072897
void ComparisonLogic::applyViewTransition(
28082898
_In_ AsicView &current,

syncd/ComparisonLogic.h

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ namespace syncd
5858
_In_ AsicView& current,
5959
_In_ AsicView& temp);
6060

61+
void transferNotProcessed(
62+
_In_ AsicView& current,
63+
_In_ AsicView& temp);
64+
6165
void checkInternalObjects(
6266
_In_ const AsicView& cv,
6367
_In_ const AsicView& tv);

0 commit comments

Comments
 (0)