Skip to content

Commit de2d6b8

Browse files
generatedunixname89002005232357meta-codesync[bot]
authored andcommitted
Revert D79321705
Summary: This diff reverts D79321705 Depends on D91360194 Failing DSF scaling tests Depends on D79321705 Differential Revision: D91360232 fbshipit-source-id: d7d318123a0cfda6f8b4e1762d99896e05cdef0b
1 parent b1593ae commit de2d6b8

File tree

5 files changed

+12
-109
lines changed

5 files changed

+12
-109
lines changed

fboss/agent/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,6 @@ cpp_library(
13171317
"//fboss/agent/rib:standalone_rib",
13181318
"//fboss/agent/state:nodebase",
13191319
"//fboss/agent/state:state",
1320-
"//fboss/agent/state:state_utils",
13211320
"//fboss/lib:common_file_utils",
13221321
"//fboss/lib:hw_write_behavior",
13231322
"//folly:file_util",

fboss/agent/HwSwitch.cpp

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "fboss/agent/hw/switch_asics/HwAsic.h"
1919
#include "fboss/agent/rib/ForwardingInformationBaseUpdater.h"
2020
#include "fboss/agent/state/StateDelta.h"
21-
#include "fboss/agent/state/StateUtils.h"
2221
#include "fboss/agent/state/SwitchState.h"
2322
#include "fboss/agent/state/TransceiverMap.h"
2423
#include "fboss/lib/HwWriteBehavior.h"
@@ -290,10 +289,6 @@ void HwSwitch::preRollback(const StateDelta& /*delta*/) noexcept {
290289
<< "Transactions is supported but rollback is implemented on this switch";
291290
}
292291

293-
void HwSwitch::rollbackPartialRoutes(const StateDelta& /* delta */) noexcept {
294-
XLOG(FATAL) << "rollbackPartialRoutes is not implemented on this switch";
295-
}
296-
297292
void HwSwitch::rollback(const std::vector<StateDelta>& /* deltas */) noexcept {
298293
XLOG(FATAL)
299294
<< "Transactions is supported but rollback is implemented on this switch";
@@ -314,16 +309,6 @@ void HwSwitch::setProgrammedState(const std::shared_ptr<SwitchState>& state) {
314309
(*programmedState)->publish();
315310
}
316311

317-
std::shared_ptr<SwitchState> HwSwitch::getIntermediateState() const {
318-
auto intermediateState = intermediateState_.rlock();
319-
return *intermediateState;
320-
}
321-
322-
void HwSwitch::setIntermediateState(const std::shared_ptr<SwitchState>& state) {
323-
auto intermediateState = intermediateState_.wlock();
324-
*intermediateState = state;
325-
}
326-
327312
fsdb::OperDelta HwSwitch::stateChanged(
328313
const std::vector<fsdb::OperDelta>& deltas,
329314
const HwWriteBehaviorRAII& /*behavior*/) {
@@ -361,38 +346,11 @@ fsdb::OperDelta HwSwitch::stateChangedTransaction(
361346
} catch (const FbossError& e) {
362347
XLOG(WARNING) << " Transaction failed with error : " << *e.message()
363348
<< " attempting rollback";
364-
365-
// If deltas were of size 10 and delta from 1-5 succeeded and 6th failed,
366-
// HwSwitch state would still be goodKnownState but SaiSwitch would have
367-
// the routes from 1-5 and the partial applied state from the 6th delta
368-
// SaiRouteManager would read from HW to reconstruct FIB and then reverse
369-
// apply the deltas to get back to known good state
370-
//
371-
// To understand next few lines of code
372-
// Step 1: If 1-5 succeeded and 6 failed, then 5 is intermediateState and
373-
// 5' is HW state. This step resets HW state from 5' -> 5.
374-
XLOG(DBG2) << "Partially rollbacking HW routes";
375-
auto hwState = this->constructSwitchStateWithFib();
376-
auto intermediateState = getIntermediateState();
377-
this->rollbackPartialRoutes(StateDelta(hwState, intermediateState));
378-
379-
// Step 2: 5 is the current HW state. We don't care about 6-10 anymore
380-
// We will generate a reverse state delta which would look like
381-
// [(5, 4), (4, 3), (3, 2), (2, 1)] from original vector
382-
auto reversedDeltas = utility::computeReversedDeltas(
383-
deltas, getProgrammedState(), getIntermediateState());
384-
385-
// Steps 3: finally insert the empty to intermediate state delta
386-
// empty -> intermediate goes first, basically to reclaim objects after
387-
// SaiStore re-init
388-
// Refer to SaiSwitch::rollback for more context about using empty
389-
// Final vector applied to HW would be
390-
// [(empty, 5), (5, 4), (4, 3), (3, 2), (2, 1)]
391-
reversedDeltas.emplace(
392-
reversedDeltas.begin(),
393-
std::make_shared<SwitchState>(),
394-
intermediateState);
395-
this->rollback(reversedDeltas);
349+
auto delta = StateDelta(getProgrammedState(), deltas.front());
350+
this->preRollback(delta);
351+
std::vector<StateDelta> goodStateDeltas;
352+
goodStateDeltas.emplace_back(getProgrammedState(), deltas.front());
353+
this->rollback(goodStateDeltas);
396354
setProgrammedState(goodKnownState);
397355
return deltas.front();
398356
}

fboss/agent/HwSwitch.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ class HwSwitch {
171171
const HwWriteBehaviorRAII& behavior =
172172
HwWriteBehaviorRAII(HwWriteBehavior::WRITE));
173173
virtual void preRollback(const StateDelta& delta) noexcept;
174-
virtual void rollbackPartialRoutes(const StateDelta& delta) noexcept;
175174
virtual void rollback(const std::vector<StateDelta>& deltas) noexcept;
176175
virtual std::shared_ptr<SwitchState> constructSwitchStateWithFib() noexcept;
177176

@@ -400,7 +399,6 @@ class HwSwitch {
400399
folly::MacAddress mac) const = 0;
401400

402401
std::shared_ptr<SwitchState> getProgrammedState() const;
403-
std::shared_ptr<SwitchState> getIntermediateState() const;
404402
fsdb::OperDelta stateChanged(
405403
const std::vector<fsdb::OperDelta>& deltas,
406404
const HwWriteBehaviorRAII& behavior =
@@ -438,7 +436,6 @@ class HwSwitch {
438436

439437
protected:
440438
void setProgrammedState(const std::shared_ptr<SwitchState>& state);
441-
void setIntermediateState(const std::shared_ptr<SwitchState>& state);
442439

443440
private:
444441
HwInitResult initLightImpl(Callback* callback, bool failHwCallsOnWarmboot);
@@ -479,7 +476,6 @@ class HwSwitch {
479476
std::optional<int64_t> switchId_;
480477

481478
folly::Synchronized<std::shared_ptr<SwitchState>> programmedState_;
482-
folly::Synchronized<std::shared_ptr<SwitchState>> intermediateState_;
483479

484480
// Collecting phy Info is currently inefficient on some platforms. Instead of
485481
// collecting them every second, tune down the frequency to only collect once

fboss/agent/hw/sai/switch/SaiSwitch.cpp

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -722,56 +722,9 @@ void SaiSwitch::preRollback(const StateDelta& delta) noexcept {
722722
}
723723
}
724724

725-
void SaiSwitch::rollbackPartialRoutes(const StateDelta& delta) noexcept {
726-
// This API called before the actual rollback
727-
728-
// During state change, assuming there are state delta vector is of size 10
729-
// If deltas were of size 10 and delta from 0-5 succeeded and 6th failed,
730-
// HwSwitch state would still be goodKnownState but SaiSwitch would have
731-
// the routes from 0-5 and the partial applied state from the 6th delta
732-
// This API will be invoked to clear partially applied delta
733-
try {
734-
CoarseGrainedLockPolicy lockPolicy(saiSwitchMutex_);
735-
736-
for (const auto& fibInfoDelta : delta.getFibsInfoDelta()) {
737-
for (const auto& routeDelta : fibInfoDelta.getFibsMapDelta()) {
738-
auto routerID = routeDelta.getOld() ? routeDelta.getOld()->getID()
739-
: routeDelta.getNew()->getID();
740-
// v6 routes first since they go after v4 during normal operation
741-
processRemovedRoutesDeltaInReverse<
742-
CoarseGrainedLockPolicy,
743-
folly::IPAddressV6>(
744-
routerID, routeDelta.getFibDelta<folly::IPAddressV6>(), lockPolicy);
745-
processChangedRoutesDeltaInReverse<
746-
CoarseGrainedLockPolicy,
747-
folly::IPAddressV6>(
748-
routerID, routeDelta.getFibDelta<folly::IPAddressV6>(), lockPolicy);
749-
processAddedRoutesDeltaInReverse<
750-
CoarseGrainedLockPolicy,
751-
folly::IPAddressV6>(
752-
routerID, routeDelta.getFibDelta<folly::IPAddressV6>(), lockPolicy);
753-
754-
processRemovedRoutesDeltaInReverse<
755-
CoarseGrainedLockPolicy,
756-
folly::IPAddressV4>(
757-
routerID, routeDelta.getFibDelta<folly::IPAddressV4>(), lockPolicy);
758-
processChangedRoutesDeltaInReverse<
759-
CoarseGrainedLockPolicy,
760-
folly::IPAddressV4>(
761-
routerID, routeDelta.getFibDelta<folly::IPAddressV4>(), lockPolicy);
762-
processAddedRoutesDeltaInReverse<
763-
CoarseGrainedLockPolicy,
764-
folly::IPAddressV4>(
765-
routerID, routeDelta.getFibDelta<folly::IPAddressV4>(), lockPolicy);
766-
}
767-
}
768-
} catch (const std::exception& ex) {
769-
// Partial route Rollback failed. Fail hard.
770-
XLOG(FATAL) << " Partial route rollback failed with : " << ex.what();
771-
}
772-
}
773-
774725
void SaiSwitch::rollback(const std::vector<StateDelta>& deltas) noexcept {
726+
CHECK_EQ(deltas.size(), 1);
727+
const auto& knownGoodState = deltas.front().oldState();
775728
auto curBootType = getBootType();
776729
// Attempt rollback
777730
// Detailed design is in the sai_switch_transactions wiki, but at a high
@@ -825,9 +778,9 @@ void SaiSwitch::rollback(const std::vector<StateDelta>& deltas) noexcept {
825778
HwWriteBehavior::FAIL,
826779
&hwSwitchJson[kAdapterKeys],
827780
&hwSwitchJson[kAdapterKey2AdapterHostKey]);
828-
for (const auto& delta : deltas) {
829-
stateChangedImplLocked(delta, lockPolicy);
830-
}
781+
stateChangedImplLocked(
782+
StateDelta(std::make_shared<SwitchState>(), knownGoodState),
783+
lockPolicy);
831784
saiStore_->printWarmbootHandles();
832785
saiStore_->removeUnexpectedUnclaimedWarmbootHandles();
833786
bootType_ = curBootType;
@@ -894,7 +847,6 @@ std::shared_ptr<SwitchState> SaiSwitch::stateChangedImpl(
894847
if (deltas.size() == 0) {
895848
return getProgrammedState();
896849
}
897-
setIntermediateState(getProgrammedState());
898850
int count = 0;
899851
std::shared_ptr<SwitchState> appliedState{nullptr};
900852
for (const auto& delta : deltas) {
@@ -906,8 +858,6 @@ std::shared_ptr<SwitchState> SaiSwitch::stateChangedImpl(
906858
<< deltas.size() << " deltas";
907859
return appliedState;
908860
}
909-
// Save the current delta that applied cleanly
910-
setIntermediateState(appliedState);
911861
count++;
912862
}
913863
return appliedState;
@@ -4999,8 +4949,9 @@ phy::FecMode SaiSwitch::getPortFECMode(PortID portId) const {
49994949
}
50004950

50014951
void SaiSwitch::rollbackInTest(const StateDelta& delta) {
4952+
preRollback(delta);
50024953
std::vector<StateDelta> deltas;
5003-
deltas.emplace_back(std::make_shared<SwitchState>(), delta.oldState());
4954+
deltas.emplace_back(delta.oldState(), delta.newState());
50044955
rollback(deltas);
50054956
setProgrammedState(delta.oldState());
50064957
}

fboss/agent/hw/sai/switch/SaiSwitch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ class SaiSwitch : public HwSwitch {
304304
const StateDelta& delta,
305305
const LockPolicyT& lk);
306306
void preRollback(const StateDelta& delta) noexcept override;
307-
void rollbackPartialRoutes(const StateDelta& delta) noexcept override;
308307
void rollback(const std::vector<StateDelta>& deltas) noexcept override;
309308
std::string listObjectsLocked(
310309
const std::vector<sai_object_type_t>& objects,

0 commit comments

Comments
 (0)