-
Notifications
You must be signed in to change notification settings - Fork 694
Warm reboot: Orchagent state restore #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
4b34c1b
17398e8
e2d262b
e4973fc
f6f2555
7c55562
e6bdeef
a4f5742
8f1700e
4324763
dc13ecc
3e034d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,7 +162,11 @@ CrmOrch::CrmOrch(DBConnector *db, string tableName): | |
| m_resourcesMap.emplace(res.first, CrmResourceEntry(res.second, CRM_THRESHOLD_TYPE_DEFAULT, CRM_THRESHOLD_LOW_DEFAULT, CRM_THRESHOLD_HIGH_DEFAULT)); | ||
| } | ||
|
|
||
| // The CRM stats needs to be populated again | ||
| m_countersCrmTable->del(CRM_COUNTERS_TABLE_KEY); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If it is applied to cold start, let's do it in another PR. #Closed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For cold start, no data exists for CRM stats table, so it has no effect. |
||
|
|
||
| auto executor = new ExecutableTimer(m_timer.get(), this); | ||
| executor->setName("CRM_COUNTERS_POLL"); | ||
| Orch::addExecutor("CRM_COUNTERS_POLL", executor); | ||
| m_timer->start(); | ||
| } | ||
|
|
@@ -333,7 +337,7 @@ void CrmOrch::decCrmAclUsedCounter(CrmResourceType resource, sai_acl_stage_t sta | |
| { | ||
| m_resourcesMap.at(resource).countersMap[getCrmAclKey(stage, point)].usedCounter--; | ||
|
|
||
| // Remove ACL table related counters | ||
| // Remove ACL table related counters | ||
| if (resource == CrmResourceType::CRM_ACL_TABLE) | ||
| { | ||
| auto & cntMap = m_resourcesMap.at(CrmResourceType::CRM_ACL_TABLE).countersMap; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,10 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName) : | |
| Orch(db, tableName, intfsorch_pri) | ||
| { | ||
| SWSS_LOG_ENTER(); | ||
|
|
||
| // Read the pre-existing data for INTF in appDB. | ||
| addExistingData(APP_INTF_TABLE_NAME); | ||
|
|
||
| } | ||
|
|
||
| sai_object_id_t IntfsOrch::getRouterIntfsId(const string &alias) | ||
|
|
@@ -86,7 +90,16 @@ void IntfsOrch::doTask(Consumer &consumer) | |
| { | ||
| if (alias == "lo") | ||
| { | ||
| addIp2MeRoute(ip_prefix); | ||
| // set request for lo may come after warm start restore | ||
|
||
| auto it_intfs = m_syncdIntfses.find(alias); | ||
| if (it_intfs == m_syncdIntfses.end()) | ||
| { | ||
| IntfsEntry intfs_entry; | ||
| intfs_entry.ref_count = 0; | ||
| m_syncdIntfses[alias] = intfs_entry; | ||
| addIp2MeRoute(ip_prefix); | ||
| } | ||
|
|
||
| it = consumer.m_toSync.erase(it); | ||
| continue; | ||
| } | ||
|
|
@@ -171,6 +184,7 @@ void IntfsOrch::doTask(Consumer &consumer) | |
| { | ||
| if (alias == "lo") | ||
| { | ||
| m_syncdIntfses.erase(alias); | ||
|
||
| removeIp2MeRoute(ip_prefix); | ||
| it = consumer.m_toSync.erase(it); | ||
| continue; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ extern "C" { | |
| #include "saihelper.h" | ||
| #include "notifications.h" | ||
| #include <signal.h> | ||
| #include <warm_restart.h> | ||
|
||
|
|
||
| using namespace std; | ||
| using namespace swss; | ||
|
|
@@ -77,6 +78,23 @@ void sighup_handler(int signo) | |
| } | ||
| } | ||
|
|
||
| void syncd_apply_view() | ||
| { | ||
| SWSS_LOG_NOTICE("Notify syncd APPLY_VIEW"); | ||
|
|
||
| sai_status_t status; | ||
| sai_attribute_t attr; | ||
| attr.id = SAI_REDIS_SWITCH_ATTR_NOTIFY_SYNCD; | ||
| attr.value.s32 = SAI_REDIS_NOTIFY_SYNCD_APPLY_VIEW; | ||
| status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); | ||
|
|
||
| if (status != SAI_STATUS_SUCCESS) | ||
| { | ||
| SWSS_LOG_ERROR("Failed to notify syncd APPLY_VIEW %d", status); | ||
| exit(EXIT_FAILURE); | ||
| } | ||
| } | ||
|
|
||
| int main(int argc, char **argv) | ||
| { | ||
| swss::Logger::linkToDbNative("orchagent"); | ||
|
|
@@ -251,6 +269,8 @@ int main(int argc, char **argv) | |
| DBConnector config_db(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); | ||
| DBConnector state_db(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); | ||
|
|
||
| WarmStart::checkWarmStart("orchagent"); | ||
|
|
||
| OrchDaemon *orchDaemon = new OrchDaemon(&appl_db, &config_db, &state_db); | ||
| if (!orchDaemon->init()) | ||
| { | ||
|
|
@@ -261,17 +281,9 @@ int main(int argc, char **argv) | |
|
|
||
| try | ||
| { | ||
| SWSS_LOG_NOTICE("Notify syncd APPLY_VIEW"); | ||
|
|
||
| attr.id = SAI_REDIS_SWITCH_ATTR_NOTIFY_SYNCD; | ||
| attr.value.s32 = SAI_REDIS_NOTIFY_SYNCD_APPLY_VIEW; | ||
| status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); | ||
|
|
||
| if (status != SAI_STATUS_SUCCESS) | ||
| if (!WarmStart::isWarmStart()) | ||
| { | ||
| SWSS_LOG_ERROR("Failed to notify syncd APPLY_VIEW %d", status); | ||
| delete orchDaemon; | ||
| exit(EXIT_FAILURE); | ||
| syncd_apply_view(); | ||
| } | ||
|
|
||
| orchDaemon->start(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,23 @@ void Consumer::drain() | |
| m_orch->doTask(*this); | ||
| } | ||
|
|
||
| void Consumer::dumpTasks(vector<string> &ts) | ||
| { | ||
| for (auto &tm :m_toSync) | ||
|
||
| { | ||
| KeyOpFieldsValuesTuple& tuple = tm.second; | ||
|
|
||
| string s = getTableName() + ":" + kfvKey(tuple) | ||
| + "|" + kfvOp(tuple); | ||
| for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++) | ||
| { | ||
| s += "|" + fvField(*i) + ":" + fvValue(*i); | ||
|
||
| } | ||
|
|
||
| ts.push_back(s); | ||
| } | ||
| } | ||
|
|
||
| bool Orch::addExistingData(const string& tableName) | ||
| { | ||
| Consumer* consumer = dynamic_cast<Consumer *>(getExecutor(tableName)); | ||
|
|
@@ -293,6 +310,21 @@ void Orch::doTask() | |
| } | ||
| } | ||
|
|
||
| void Orch::dumpTasks(vector<string> &ts) | ||
| { | ||
| for(auto &it : m_consumerMap) | ||
| { | ||
| Consumer* consumer = dynamic_cast<Consumer *>(it.second.get()); | ||
| if (consumer == NULL) | ||
| { | ||
| SWSS_LOG_DEBUG("Executor is not a Consumer"); | ||
| continue; | ||
| } | ||
|
|
||
| consumer->dumpTasks(ts); | ||
| } | ||
| } | ||
|
|
||
| void Orch::logfileReopen() | ||
| { | ||
| gRecordOfs.close(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,10 +91,22 @@ class Executor : public Selectable | |
| virtual void execute() { } | ||
| virtual void drain() { } | ||
|
|
||
| virtual string getName() const | ||
| { | ||
| return m_name; | ||
| } | ||
| virtual void setName(string name) | ||
| { | ||
| m_name = name; | ||
| } | ||
|
|
||
| protected: | ||
| Selectable *m_selectable; | ||
| Orch *m_orch; | ||
|
|
||
| // Name for Executor | ||
| string m_name; | ||
|
|
||
| // Get the underlying selectable | ||
| Selectable *getSelectable() const { return m_selectable; } | ||
| }; | ||
|
|
@@ -116,10 +128,24 @@ class Consumer : public Executor { | |
| return getConsumerTable()->getTableName(); | ||
| } | ||
|
|
||
|
|
||
| string getName() const | ||
| { | ||
| return getConsumerTable()->getTableName(); | ||
| } | ||
|
|
||
| int getDbId() const | ||
| { | ||
| return getConsumerTable()->getDbId(); | ||
| } | ||
|
|
||
| void dumpTasks(vector<string> &ts); | ||
|
|
||
| void addToSync(std::deque<KeyOpFieldsValuesTuple> &entries); | ||
| void refillToSync(); | ||
| void refillToSync(Table* table); | ||
| void execute(); | ||
|
||
|
|
||
| void drain(); | ||
|
|
||
| /* Store the latest 'golden' status */ | ||
|
|
@@ -166,6 +192,8 @@ class Orch | |
|
|
||
| /* TODO: refactor recording */ | ||
| static void recordTuple(Consumer &consumer, KeyOpFieldsValuesTuple &tuple); | ||
|
|
||
| void dumpTasks(vector<string> &ts); | ||
| protected: | ||
| ConsumerMap m_consumerMap; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just change the constructor to set the name.
not sure if it is useful to introduce setName method, since we do not (probably should not) allow change the name.