-
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 9 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 |
|---|---|---|
|
|
@@ -26,14 +26,14 @@ FdbOrch::FdbOrch(DBConnector *db, string tableName, PortsOrch *port) : | |
| { | ||
| m_portsOrch->attach(this); | ||
| m_flushNotificationsConsumer = new NotificationConsumer(db, "FLUSHFDBREQUEST"); | ||
| auto flushNotifier = new Notifier(m_flushNotificationsConsumer, this); | ||
| Orch::addExecutor("", flushNotifier); | ||
| auto flushNotifier = new Notifier(m_flushNotificationsConsumer, this, "FLUSHFDBREQUEST"); | ||
| Orch::addExecutor(flushNotifier); | ||
|
|
||
| /* Add FDB notifications support from ASIC */ | ||
| DBConnector *notificationsDb = new DBConnector(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); | ||
| m_fdbNotificationConsumer = new swss::NotificationConsumer(notificationsDb, "NOTIFICATIONS"); | ||
| auto fdbNotifier = new Notifier(m_fdbNotificationConsumer, this); | ||
| Orch::addExecutor("FDB_NOTIFICATIONS", fdbNotifier); | ||
| auto fdbNotifier = new Notifier(m_fdbNotificationConsumer, this, "FDB_NOTIFICATIONS"); | ||
| Orch::addExecutor(fdbNotifier); | ||
| } | ||
|
|
||
| void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_object_id_t bridge_port_id) | ||
|
|
@@ -53,6 +53,14 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj | |
| return; | ||
| } | ||
|
|
||
| // we already have such entries | ||
| if (m_entries.count(update.entry) != 0) | ||
|
||
| { | ||
| SWSS_LOG_INFO("FdbOrch notification: mac %s is already in bv_id 0x%lx", | ||
| update.entry.mac.to_string().c_str(), entry->bv_id); | ||
| break; | ||
| } | ||
|
|
||
| update.add = true; | ||
|
|
||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,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 +180,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,11 +78,29 @@ 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"); | ||
|
|
||
| SWSS_LOG_ENTER(); | ||
| WarmStart::checkWarmStart("orchagent"); | ||
|
|
||
| if (signal(SIGHUP, sighup_handler) == SIG_ERR) | ||
| { | ||
|
|
@@ -261,17 +280,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 |
|---|---|---|
|
|
@@ -185,6 +185,30 @@ void Consumer::drain() | |
| m_orch->doTask(*this); | ||
| } | ||
|
|
||
| string Consumer::dumpTuple(KeyOpFieldsValuesTuple &tuple) | ||
| { | ||
| string s = getTableName() + getConsumerTable()->getTableNameSeparator() + kfvKey(tuple) | ||
| + "|" + kfvOp(tuple); | ||
|
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.
getTableNameSeparator() could be '|', do you want to change this '|'? #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. This a good question. |
||
| for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++) | ||
| { | ||
| s += "|" + fvField(*i) + ":" + fvValue(*i); | ||
| } | ||
|
|
||
| return s; | ||
| } | ||
|
|
||
| void Consumer::dumpToSyncTasks(vector<string> &ts) | ||
|
||
| { | ||
| for (auto &tm :m_toSync) | ||
|
||
| { | ||
| KeyOpFieldsValuesTuple& tuple = tm.second; | ||
|
|
||
| string s = dumpTuple(tuple); | ||
|
|
||
| ts.push_back(s); | ||
| } | ||
| } | ||
|
|
||
| size_t Orch::addExistingData(const string& tableName) | ||
| { | ||
| auto consumer = dynamic_cast<Consumer *>(getExecutor(tableName)); | ||
|
|
@@ -224,7 +248,7 @@ bool Orch::bake() | |
| { | ||
| continue; | ||
| } | ||
|
|
||
| size_t refilled = consumer->refillToSync(); | ||
| SWSS_LOG_NOTICE("Add warm input: %s, %zd", executorName.c_str(), refilled); | ||
| } | ||
|
|
@@ -326,6 +350,21 @@ void Orch::doTask() | |
| } | ||
| } | ||
|
|
||
| void Orch::dumpToSyncTasks(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->dumpToSyncTasks(ts); | ||
| } | ||
| } | ||
|
|
||
| void Orch::logfileReopen() | ||
| { | ||
| gRecordOfs.close(); | ||
|
|
@@ -347,12 +386,7 @@ void Orch::logfileReopen() | |
|
|
||
| void Orch::recordTuple(Consumer &consumer, KeyOpFieldsValuesTuple &tuple) | ||
| { | ||
| string s = consumer.getTableName() + ":" + kfvKey(tuple) | ||
| + "|" + kfvOp(tuple); | ||
| for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++) | ||
| { | ||
| s += "|" + fvField(*i) + ":" + fvValue(*i); | ||
| } | ||
| string s = consumer.dumpTuple(tuple); | ||
|
|
||
| gRecordOfs << getTimestamp() << "|" << s << endl; | ||
|
|
||
|
|
@@ -366,13 +400,7 @@ void Orch::recordTuple(Consumer &consumer, KeyOpFieldsValuesTuple &tuple) | |
|
|
||
| string Orch::dumpTuple(Consumer &consumer, KeyOpFieldsValuesTuple &tuple) | ||
| { | ||
| string s = consumer.getTableName() + ":" + kfvKey(tuple) | ||
| + "|" + kfvOp(tuple); | ||
| for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++) | ||
| { | ||
| s += "|" + fvField(*i) + ":" + fvValue(*i); | ||
| } | ||
|
|
||
| string s = consumer.dumpTuple(tuple); | ||
| return s; | ||
| } | ||
|
|
||
|
|
@@ -461,18 +489,18 @@ void Orch::addConsumer(DBConnector *db, string tableName, int pri) | |
| { | ||
| if (db->getDbId() == CONFIG_DB || db->getDbId() == STATE_DB) | ||
| { | ||
| addExecutor(tableName, new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this)); | ||
| addExecutor(new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this, tableName)); | ||
| } | ||
| else | ||
| { | ||
| addExecutor(tableName, new Consumer(new ConsumerStateTable(db, tableName, gBatchSize, pri), this)); | ||
| addExecutor(new Consumer(new ConsumerStateTable(db, tableName, gBatchSize, pri), this, tableName)); | ||
| } | ||
| } | ||
|
|
||
| void Orch::addExecutor(string executorName, Executor* executor) | ||
| void Orch::addExecutor(Executor* executor) | ||
| { | ||
| m_consumerMap.emplace(std::piecewise_construct, | ||
| std::forward_as_tuple(executorName), | ||
| std::forward_as_tuple(executor->getName()), | ||
| std::forward_as_tuple(executor)); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
If it is applied to cold start, let's do it in another PR. #Closed
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.
For cold start, no data exists for CRM stats table, so it has no effect.