Skip to content

Commit

Permalink
Fix a bug in reporting tcvr state to fsdb
Browse files Browse the repository at this point in the history
Summary:
Adding D62225846 back. Was backed out for failing fsdb tests in link test.

QSFP service will not report absent transceivers to fsdb, which is ok until a transceiver is plugged out or failed.
This diff reports all transceiver states to fsdb, which can be used by netstate etc. to detect failed transceivers much better.

Reviewed By: harshitgulati18

Differential Revision: D62785834

fbshipit-source-id: ce40e82168b6d97c10335cdda5bab3d366b6c1f7
  • Loading branch information
Mohammed Al-Sanabani authored and facebook-github-bot committed Sep 19, 2024
1 parent aa52a7e commit e41e6ee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
2 changes: 1 addition & 1 deletion fboss/qsfp_service/TransceiverManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,7 @@ std::vector<TransceiverID> TransceiverManager::refreshTransceivers(
XLOG(INFO) << "Finished refreshing " << nTransceivers << " transceivers";
}

publishTransceiversToFsdb(transceiverIds);
publishTransceiversToFsdb();

return transceiverIds;
}
Expand Down
3 changes: 1 addition & 2 deletions fboss/qsfp_service/TransceiverManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ class TransceiverManager {
const std::unordered_set<TransceiverID>& transceivers);

/// Called to publish transceivers after a refresh
virtual void publishTransceiversToFsdb(
const std::vector<TransceiverID>& ids) = 0;
virtual void publishTransceiversToFsdb() = 0;

virtual int scanTransceiverPresence(
std::unique_ptr<std::vector<int32_t>> ids) = 0;
Expand Down
23 changes: 4 additions & 19 deletions fboss/qsfp_service/platforms/wedge/WedgeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,32 +488,17 @@ void WedgeManager::updateTcvrStateInFsdb(
fsdbSyncManager_->updateTcvrState(tcvrID, std::move(newState));
}

void WedgeManager::publishTransceiversToFsdb(
const std::vector<TransceiverID>& ids) {
void WedgeManager::publishTransceiversToFsdb() {
if (!FLAGS_publish_stats_to_fsdb) {
return;
}

// Get the transceiver info for all transceivers
TcvrInfoMap tcvrInfos;
getTransceiversInfo(tcvrInfos, std::make_unique<std::vector<int32_t>>());

// Publish states on refreshed transceivers
for (int32_t id : ids.empty() ? folly::gen::range(0, getNumQsfpModules()) |
folly::gen::eachAs<TransceiverID>() |
folly::gen::as<std::vector<TransceiverID>>()
: ids) {
auto iter = tcvrInfos.find(id);
if (iter == tcvrInfos.end()) {
continue;
}
updateTcvrStateInFsdb(
TransceiverID(id), std::move(*iter->second.tcvrState()));
}

// Publish all stats (No deltas. Just publish the best we have for all
// transceivers.)
QsfpFsdbSyncManager::TcvrStatsMap stats;
for (const auto& [id, info] : tcvrInfos) {
for (auto& [id, info] : tcvrInfos) {
updateTcvrStateInFsdb(TransceiverID(id), std::move(*info.tcvrState()));
stats[id] = *info.tcvrStats();
}
fsdbSyncManager_->updateTcvrStats(std::move(stats));
Expand Down
3 changes: 1 addition & 2 deletions fboss/qsfp_service/platforms/wedge/WedgeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ class WedgeManager : public TransceiverManager {
return 16;
}
std::vector<TransceiverID> refreshTransceivers() override;
void publishTransceiversToFsdb(
const std::vector<TransceiverID>& ids) override;
void publishTransceiversToFsdb() override;

int scanTransceiverPresence(
std::unique_ptr<std::vector<int32_t>> ids) override;
Expand Down

0 comments on commit e41e6ee

Please sign in to comment.