Skip to content

Commit caa7ab2

Browse files
authored
Fix Warmboot Issue when upgraded Image SAI return Switch Internal OID not accounted in previous image. (sonic-net#654)
* Fix the issue sonic-net#5274 Basically Switch Internal OID should always be accounted in Temp and Current Logic Comparison. It should never trigger remove operation. Changes is to always add Switch Internal OID to COLDVIDS (even in case of warm-boot) Signed-off-by: Abhishek Dosi <[email protected]> * Fix the API that check NonRemovableOID to check internal OID first before Cold Bott Discover OID. Also address review Comments. * Address Review Comments Signed-off-by: Abhishek Dosi <[email protected]>
1 parent 9c80626 commit caa7ab2

File tree

2 files changed

+46
-10
lines changed

2 files changed

+46
-10
lines changed

syncd/SaiSwitch.cpp

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ sai_object_id_t SaiSwitch::helperGetSwitchAttrOid(
517517
* Redis value of this attribute is not present yet, save it!
518518
*/
519519

520-
redisSetDummyAsicStateForRealObjectId(rid);
520+
redisSaveInternalOids(rid);
521521

522522
SWSS_LOG_INFO("redis %s id is not defined yet in redis", meta->attridname);
523523

@@ -611,25 +611,29 @@ bool SaiSwitch::isNonRemovableRid(
611611
SWSS_LOG_THROW("NULL rid passed");
612612
}
613613

614-
if (!isColdBootDiscoveredRid(rid))
615-
{
616-
/*
617-
* This object was not discovered on cold boot so it can be removed.
618-
*/
619-
620-
return false;
621-
}
622-
623614
/*
624615
* Check for SAI_SWITCH_ATTR_DEFAULT_* oids like cpu, default virtual
625616
* router. Those objects can't be removed if user ask for it.
626617
*/
627618

619+
/* Here we are checking for isSwitchObjectDefaultRid first then ColdBootDiscoveredRid
620+
* as it is possible we can discover switch Internal OID as part of warm-booot also especially
621+
* when we are doing SAI upgrade as part of warm-boot.*/
622+
628623
if (isSwitchObjectDefaultRid(rid))
629624
{
630625
return true;
631626
}
632627

628+
if (!isColdBootDiscoveredRid(rid))
629+
{
630+
/*
631+
* This object was not discovered on cold boot so it can be removed.
632+
*/
633+
634+
return false;
635+
}
636+
633637
sai_object_type_t ot = m_vendorSai->objectTypeQuery(rid);
634638

635639
/*
@@ -744,6 +748,35 @@ std::set<sai_object_id_t> SaiSwitch::getWarmBootDiscoveredVids() const
744748
return m_warmBootDiscoveredVids;
745749
}
746750

751+
void SaiSwitch::redisSaveInternalOids(
752+
_In_ sai_object_id_t rid) const
753+
{
754+
SWSS_LOG_ENTER();
755+
756+
std::set<sai_object_id_t> coldVids;
757+
758+
sai_object_id_t vid = m_translator->translateRidToVid(rid, m_switch_vid);
759+
760+
coldVids.insert(vid);
761+
762+
/* Save Switch Internal OID put in current view asic state and also
763+
* in ColdVid Table discovered as cold or warm boot.
764+
* Please note it is possible to discover new Switch internal OID in warm-boot also
765+
* if SAI gets upgraded as part of warm-boot so we are adding to ColdVid also
766+
* so that comparison logic do not remove this OID in warm-boot case. One example
767+
* is SAI_SWITCH_ATTR_DEFAULT_STP_INST_ID which is discovered in warm-boot
768+
* when upgrading to new SAI Version*/
769+
770+
771+
m_client->setDummyAsicStateObject(vid);
772+
773+
m_client->saveColdBootDiscoveredVids(m_switch_vid, coldVids);
774+
775+
SWSS_LOG_NOTICE("put switch internal discovered rid %s to Asic View and COLDVIDS",
776+
sai_serialize_object_id(rid).c_str());
777+
778+
}
779+
747780
void SaiSwitch::redisSaveColdBootDiscoveredVids() const
748781
{
749782
SWSS_LOG_ENTER();

syncd/SaiSwitch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ namespace syncd
299299

300300
void helperInternalOids();
301301

302+
void redisSaveInternalOids(
303+
_In_ sai_object_id_t rid) const;
304+
302305
void helperLoadColdVids();
303306

304307
void helperPopulateWarmBootVids();

0 commit comments

Comments
 (0)