Skip to content

Commit

Permalink
clear faults raised for encap mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavanaashok33 committed May 16, 2023
1 parent 5c61d13 commit 183e914
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
1 change: 1 addition & 0 deletions agent-ovs/lib/FaultManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ void FaultManager::removeFault(const std::string& uuid){
Mutator mutator_policyelem(agent.getFramework(), "policyelement");
auto fu = modelgbp::fault::Instance::resolve(agent.getFramework(),uuid);
if (fu){
LOG(INFO) << "Removing the fault instance using the uuid = "<<uuid;
fu.get()->remove(agent.getFramework(), uuid);
mutator_policyelem.commit();
}
Expand Down
12 changes: 11 additions & 1 deletion agent-ovs/lib/include/opflexagent/Fault.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,25 @@ class Fault {
return egURI;
}


void setAffectedObject(const std::string& affectedObject) {
this->affectedobject = affectedObject;
}


const std::string& getAffectedObject() const {
return affectedobject;
}

private:
std::string ep_uuid;
std::string fs_uuid;
uint64_t faultcode;
uint8_t severity;
std::string description;
std::string affectedobject;
boost::optional<opflex::modb::MAC> mac;
boost::optional<opflex::modb::URI> egURI;

};

/**
Expand Down
31 changes: 20 additions & 11 deletions agent-ovs/ovs/IntFlowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <opflexagent/Endpoint.h>
#include <opflexagent/EndpointManager.h>
#include <opflexagent/Faults.h>
#include <opflexagent/FSFaultSource.h>
#include <opflexagent/FaultManager.h>

#include "SwitchConnection.h"
#include "IntFlowManager.h"
Expand Down Expand Up @@ -143,6 +145,7 @@ IntFlowManager::IntFlowManager(Agent& agent_,
conntrackEnabled(false), dhcpMac{}, dropLogRemotePort(0),
serviceStatsFlowDisabled(false),
advertManager(agent, *this), isSyncing(false), stopping(false),
faultmanager(agent.getFaultManager()),
svcStatsTaskQueue(svcStatsIOService) {
// set up flow tables
switchManager.setMaxFlowTables(NUM_FLOW_TABLES);
Expand Down Expand Up @@ -537,20 +540,26 @@ void IntFlowManager::configUpdated(const URI& configURI) {
if (config_opt) {
optional<const uint8_t> configEncapType =
config_opt.get()->getEncapType();
string fsuuid = "8encapmismatchconfig";

if (configEncapType && configEncapType.get() != encapType) {
LOG(INFO) << "fault raised for encapType from fabric doesn't match "
"agent config";
auto fu = modelgbp::fault::Universe::resolve(agent.getFramework());
opflex::modb::Mutator mutator(agent.getFramework(),
"policyelement");
auto fi = fu.get()->addFaultInstance(to_string(uuidGen()));
fi->setDescription(
"encapType from fabric doesn't match agent config");
fi->setSeverity(modelgbp::fault::SeverityEnumT::CONST_CRITICAL);
fi->setAffectedObject(configURI.toString());
fi->setFaultCode(opflexagent::FaultCodes::ENCAP_MISMATCH);
mutator.commit();
}

Fault newfs;
newfs.setFSUUID(fsuuid);
newfs.setSeverity(modelgbp::fault::SeverityEnumT::CONST_CRITICAL);
newfs.setDescription("encapType from fabric doesn't match agent config");
newfs.setFaultcode(opflexagent::FaultCodes::ENCAP_MISMATCH);
newfs.setAffectedObject(configURI.toString());
faultmanager.createPlatformFault(newfs);
} else if (configEncapType && configEncapType.get() == encapType) {
Mutator mutator_policyelem(agent.getFramework(), "policyelement");
auto fu = modelgbp::fault::Instance::resolve(agent.getFramework(),fsuuid);
if (fu) {
faultmanager.removeFault(fsuuid);
}
}
}
switchManager.enableSync();
agent.getAgentIOService()
Expand Down
2 changes: 2 additions & 0 deletions agent-ovs/ovs/include/IntFlowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "SwitchStateHandler.h"

#include <opflex/ofcore/PeerStatusListener.h>
#include <opflexagent/FaultManager.h>

#include <boost/asio/ip/address.hpp>
#include <boost/optional.hpp>
Expand Down Expand Up @@ -979,6 +980,7 @@ class IntFlowManager : public SwitchStateHandler,
std::unique_ptr<std::thread> svcStatsThread;
boost::asio::io_service svcStatsIOService;
std::unique_ptr<boost::asio::io_service::work> svcStatsIOWork;
FaultManager& faultmanager;
TaskQueue svcStatsTaskQueue;
};

Expand Down
10 changes: 10 additions & 0 deletions agent-ovs/ovs/test/IntFlowManager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4601,6 +4601,16 @@ BOOST_FIXTURE_TEST_CASE(testencapfault, BaseIntFlowManagerFixture) {
WAIT_FOR(modelgbp::platform::Config::resolve(framework, platformCfg->getURI()), 500);

intFlowManager.configUpdated(platformCfg->getURI());

Mutator mutator_ex(framework, "policyreg");
auto polUni2 =
modelgbp::policy::Universe::resolve(framework).get();
auto platformCfg2 = polUni2->addPlatformConfig("dummy");
platformCfg2->setEncapType(EncapTypeEnumT::CONST_VLAN);
mutator_ex.commit();
WAIT_FOR(modelgbp::platform::Config::resolve(framework, platformCfg2->getURI()), 500);
intFlowManager.configUpdated(platformCfg2->getURI());

stop();
}

Expand Down

0 comments on commit 183e914

Please sign in to comment.