diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 62c6b4956f73..9de842142d4d 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -635,6 +635,38 @@ task_process_status BufferOrch::processEgressBufferProfileList(Consumer &consume return task_process_status::task_success; } +void BufferOrch::doTask() +{ + // The hidden dependency tree: + // ref: https://github.com/opencomputeproject/SAI/blob/master/doc/QOS/SAI-Proposal-buffers-Ver4.docx + // 2 SAI model + // 3.1 Ingress priority group (PG) configuration + // 3.2.1 Buffer profile configuration + // + // buffer pool + // └── buffer profile + // ├── buffer port ingress profile list + // ├── buffer port egress profile list + // ├── buffer queue + // └── buffer pq table + + auto pool_consumer = getExecutor((CFG_BUFFER_POOL_TABLE_NAME)); + pool_consumer->drain(); + + auto profile_consumer = getExecutor(CFG_BUFFER_PROFILE_TABLE_NAME); + profile_consumer->drain(); + + for(auto &it : m_consumerMap) + { + auto consumer = it.second.get(); + if (consumer == profile_consumer) + continue; + if (consumer == pool_consumer) + continue; + consumer->drain(); + } +} + void BufferOrch::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); diff --git a/orchagent/bufferorch.h b/orchagent/bufferorch.h index 23f56e614740..f5811fdbd28f 100644 --- a/orchagent/bufferorch.h +++ b/orchagent/bufferorch.h @@ -35,6 +35,7 @@ class BufferOrch : public Orch typedef map buffer_table_handler_map; typedef pair buffer_handler_pair; + virtual void doTask() override; virtual void doTask(Consumer& consumer); void initTableHandlers(); void initBufferReadyLists(DBConnector *db); diff --git a/orchagent/orch.h b/orchagent/orch.h index dfbadb62bff3..03f18f4f8d4c 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -182,7 +182,7 @@ class Orch virtual bool bake(); /* Iterate all consumers in m_consumerMap and run doTask(Consumer) */ - void doTask(); + virtual void doTask(); /* Run doTask against a specific executor */ virtual void doTask(Consumer &consumer) = 0; diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 0fd5a24e46b9..9f837c5618c6 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -264,7 +264,11 @@ bool OrchDaemon::init() if (WarmStart::isWarmStart()) { - warmRestoreAndSyncUp(); + bool suc = warmRestoreAndSyncUp(); + if (!suc) + { + return false; + } } return true; @@ -336,7 +340,7 @@ void OrchDaemon::start() * Try to perform orchagent state restore and dynamic states sync up if * warm start reqeust is detected. */ -void OrchDaemon::warmRestoreAndSyncUp() +bool OrchDaemon::warmRestoreAndSyncUp() { WarmStart::setWarmStartState("orchagent", WarmStart::INIT); @@ -366,7 +370,12 @@ void OrchDaemon::warmRestoreAndSyncUp() * orchagent should be in exact same state of pre-shutdown. * Perform restore validation as needed. */ - warmRestoreValidation(); + bool suc = warmRestoreValidation(); + if (!suc) + { + SWSS_LOG_ERROR("Orchagent state restore failed"); + return false; + } SWSS_LOG_NOTICE("Orchagent state restore done"); @@ -377,6 +386,7 @@ void OrchDaemon::warmRestoreAndSyncUp() * The "RECONCILED" state of orchagent doesn't mean the state related to neighbor is up to date. */ WarmStart::setWarmStartState("orchagent", WarmStart::RECONCILED); + return true; } /* diff --git a/orchagent/orchdaemon.h b/orchagent/orchdaemon.h index 53210b74772f..3d6e82b4fa31 100644 --- a/orchagent/orchdaemon.h +++ b/orchagent/orchdaemon.h @@ -34,7 +34,7 @@ class OrchDaemon bool init(); void start(); - void warmRestoreAndSyncUp(); + bool warmRestoreAndSyncUp(); void getTaskToSync(vector &ts); bool warmRestoreValidation(); private: