@@ -184,10 +184,13 @@ class SaiObjectStore {
184184 keys.end ());
185185 }
186186 for (const auto & k : keys) {
187- ObjectType obj = getObject (k, adapterKeys2AdapterHostKey);
188- auto adapterHostKey = obj.adapterHostKey ();
189- XLOGF (DBG5 , " SaiStore reloaded {}" , obj);
190- auto ins = objects_.refOrInsert (adapterHostKey, std::move (obj));
187+ auto obj = getObjectIfInHw (k, adapterKeys2AdapterHostKey);
188+ if (!obj) {
189+ continue ;
190+ }
191+ auto adapterHostKey = obj->adapterHostKey ();
192+ XLOGF (DBG5 , " SaiStore reloaded {}" , *obj);
193+ auto ins = objects_.refOrInsert (adapterHostKey, std::move (*obj));
191194 if (!ins.second ) {
192195 XLOG (FATAL ) << " [" << saiObjectTypeToString (SaiObjectTraits::ObjectType)
193196 << " ]" << " Unexpected duplicate adapterHostKey" ;
@@ -495,6 +498,37 @@ class SaiObjectStore {
495498 });
496499 }
497500
501+ /*
502+ * Warm boot reloads objects from adapter keys saved at graceful exit. For
503+ * object types hardware can delete on its own, that snapshot is only a best
504+ * effort: e.g. a dynamic FDB entry can age out after the keys are written, or
505+ * after an age event the agent never got to process. Skip such keys instead
506+ * of letting the missing object abort warm boot - switch state replays
507+ * whatever is still needed, and removeUnclaimedDynanicEntries() cleans up the
508+ * rest.
509+ */
510+ std::optional<ObjectType> getObjectIfInHw (
511+ const typename SaiObjectTraits::AdapterKey& key,
512+ const folly::dynamic* adapterKeys2AdapterHostKey) {
513+ if constexpr (SaiObjectMayBeMissingInHw<SaiObjectTraits>::value) {
514+ try {
515+ return getObject (key, adapterKeys2AdapterHostKey);
516+ } catch (const SaiApiError& e) {
517+ if (e.getSaiStatus () != SAI_STATUS_ITEM_NOT_FOUND ) {
518+ throw ;
519+ }
520+ XLOGF (
521+ WARN ,
522+ " [{}] skipping {} on reload, no longer present in hardware" ,
523+ objectTypeName ().str (),
524+ key);
525+ return std::nullopt ;
526+ }
527+ } else {
528+ return getObject (key, adapterKeys2AdapterHostKey);
529+ }
530+ }
531+
498532 ObjectType getObject (
499533 typename ObjectTraits::AdapterKey key,
500534 const folly::dynamic* adapterKey2AdapterHostKey) {
0 commit comments