Skip to content

Commit

Permalink
Merge "Improve Control-Node IFMAP debug-ability in pre-4.0 releases" …
Browse files Browse the repository at this point in the history
…into R3.2
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed May 29, 2018
2 parents 7572863 + e78d2b3 commit 7233049
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/bgp/bgp_xmpp_channel.cc
Expand Up @@ -2531,7 +2531,7 @@ void BgpXmppChannelManager::XmppHandleChannelEvent(XmppChannel *channel,
"Received XmppChannel up event");
if (!bgp_server_->HasSelfConfiguration()) {
BGP_LOG_PEER(Message, bgp_xmpp_channel->Peer(),
SandeshLevel::SYS_INFO, BGP_LOG_FLAG_SYSLOG,
SandeshLevel::SYS_WARN, BGP_LOG_FLAG_SYSLOG,
BGP_PEER_DIR_IN,
"No BGP configuration for self - closing channel");
channel->Close();
Expand Down
17 changes: 14 additions & 3 deletions src/control-node/test/options_test.cc
Expand Up @@ -76,6 +76,7 @@ TEST_F(OptionsTest, NoArguments) {
EXPECT_EQ(options_.ifmap_user(), "control-node");
EXPECT_EQ(options_.ifmap_certs_store(), "");
EXPECT_EQ(options_.ifmap_stale_entries_cleanup_timeout(), 300);
EXPECT_EQ(options_.ifmap_stale_or_eor_timeout_increment(), 45);
EXPECT_EQ(options_.ifmap_end_of_rib_timeout(), 10);
EXPECT_EQ(options_.ifmap_peer_response_wait_time(), 60);
EXPECT_EQ(options_.xmpp_port(), default_xmpp_port);
Expand Down Expand Up @@ -119,6 +120,7 @@ TEST_F(OptionsTest, DefaultConfFile) {
EXPECT_EQ(options_.ifmap_user(), "control-node");
EXPECT_EQ(options_.ifmap_certs_store(), "");
EXPECT_EQ(options_.ifmap_stale_entries_cleanup_timeout(), 300);
EXPECT_EQ(options_.ifmap_stale_or_eor_timeout_increment(), 45);
EXPECT_EQ(options_.ifmap_end_of_rib_timeout(), 10);
EXPECT_EQ(options_.ifmap_peer_response_wait_time(), 60);
EXPECT_EQ(options_.xmpp_port(), default_xmpp_port);
Expand Down Expand Up @@ -251,6 +253,7 @@ TEST_F(OptionsTest, CustomConfigFile) {
"server_url=https://127.0.0.1:100\n"
"user=test-user\n"
"stale_entries_cleanup_timeout=120\n"
"stale_or_eor_timeout_increment=30\n"
"end_of_rib_timeout=110\n"
"peer_response_wait_time=100\n";

Expand Down Expand Up @@ -296,6 +299,7 @@ TEST_F(OptionsTest, CustomConfigFile) {
EXPECT_EQ(options_.ifmap_user(), "test-user");
EXPECT_EQ(options_.ifmap_certs_store(), "test-store");
EXPECT_EQ(options_.ifmap_stale_entries_cleanup_timeout(), 120);
EXPECT_EQ(options_.ifmap_stale_or_eor_timeout_increment(), 30);
EXPECT_EQ(options_.ifmap_end_of_rib_timeout(), 110);
EXPECT_EQ(options_.ifmap_peer_response_wait_time(), 100);
EXPECT_EQ(options_.xmpp_port(), 100);
Expand Down Expand Up @@ -526,7 +530,7 @@ TEST_F(OptionsTest, UnresolvableHostName) {
}

TEST_F(OptionsTest, OverrideIFMapOptionsFromCommandLine) {
int argc = 9;
int argc = 10;
char *argv[argc];
char argv_0[] = "options_test";
char argv_1[] = "--conf_file=controller/src/control-node/contrail-control.conf";
Expand All @@ -537,6 +541,7 @@ TEST_F(OptionsTest, OverrideIFMapOptionsFromCommandLine) {
char argv_6[] = "--IFMAP.stale_entries_cleanup_timeout=99";
char argv_7[] = "--IFMAP.end_of_rib_timeout=88";
char argv_8[] = "--IFMAP.peer_response_wait_time=77";
char argv_9[] = "--IFMAP.stale_or_eor_timeout_increment=22";
argv[0] = argv_0;
argv[1] = argv_1;
argv[2] = argv_2;
Expand All @@ -546,6 +551,7 @@ TEST_F(OptionsTest, OverrideIFMapOptionsFromCommandLine) {
argv[6] = argv_6;
argv[7] = argv_7;
argv[8] = argv_8;
argv[9] = argv_9;

options_.Parse(evm_, argc, argv);

Expand All @@ -556,6 +562,7 @@ TEST_F(OptionsTest, OverrideIFMapOptionsFromCommandLine) {
EXPECT_EQ(options_.ifmap_stale_entries_cleanup_timeout(), 99); // default 10
EXPECT_EQ(options_.ifmap_end_of_rib_timeout(), 88); // default 10
EXPECT_EQ(options_.ifmap_peer_response_wait_time(), 77); // default 60
EXPECT_EQ(options_.ifmap_stale_or_eor_timeout_increment(), 22); // default 45
}

TEST_F(OptionsTest, CustomIFMapConfigFileAndOverrideFromCommandLine) {
Expand All @@ -567,14 +574,15 @@ TEST_F(OptionsTest, CustomIFMapConfigFileAndOverrideFromCommandLine) {
"user=test-user\n"
"stale_entries_cleanup_timeout=120\n"
"end_of_rib_timeout=110\n"
"peer_response_wait_time=100\n";
"peer_response_wait_time=100\n"
"stale_or_eor_timeout_increment=40";

ofstream config_file;
config_file.open("./options_test_config_file.conf");
config_file << config;
config_file.close();

int argc = 9;
int argc = 10;
char *argv[argc];
char argv_0[] = "options_test";
char argv_1[] = "--conf_file=./options_test_config_file.conf";
Expand All @@ -585,6 +593,7 @@ TEST_F(OptionsTest, CustomIFMapConfigFileAndOverrideFromCommandLine) {
char argv_6[] = "--IFMAP.end_of_rib_timeout=31";
char argv_7[] = "--IFMAP.peer_response_wait_time=41";
char argv_8[] = "--IFMAP.user=new-test-user";
char argv_9[] = "--IFMAP.stale_or_eor_timeout_increment=1";
argv[0] = argv_0;
argv[1] = argv_1;
argv[2] = argv_2;
Expand All @@ -594,6 +603,7 @@ TEST_F(OptionsTest, CustomIFMapConfigFileAndOverrideFromCommandLine) {
argv[6] = argv_6;
argv[7] = argv_7;
argv[8] = argv_8;
argv[9] = argv_9;

options_.Parse(evm_, argc, argv);

Expand All @@ -604,6 +614,7 @@ TEST_F(OptionsTest, CustomIFMapConfigFileAndOverrideFromCommandLine) {
EXPECT_EQ(options_.ifmap_end_of_rib_timeout(), 31);
EXPECT_EQ(options_.ifmap_peer_response_wait_time(), 41);
EXPECT_EQ(options_.ifmap_user(), "new-test-user");
EXPECT_EQ(options_.ifmap_stale_or_eor_timeout_increment(), 1);
}

int main(int argc, char **argv) {
Expand Down
16 changes: 8 additions & 8 deletions src/ifmap/client/ifmap_channel.cc
Expand Up @@ -85,7 +85,7 @@ void IFMapChannel::ChannelUseCertAuth(const std::string& certstore)
char hostname[1024];
struct addrinfo hints, *info;

IFMAP_PEER_DEBUG(IFMapServerConnection, "Certificate Store is", certstore);
IFMAP_PEER_NOTICE(IFMapServerConnection, "Certificate Store is", certstore);

// get host FQDN; eg a2s8.contrail.juniper.net
hostname[sizeof(hostname)-1] = '\0';
Expand All @@ -104,7 +104,7 @@ void IFMapChannel::ChannelUseCertAuth(const std::string& certstore)

// certificate files - follow puppet convention and subdirs
certname = string(hostname) + ".pem";
IFMAP_PEER_DEBUG(IFMapServerConnection, "Certificate name is", certname);
IFMAP_PEER_NOTICE(IFMapServerConnection, "Certificate name is", certname);

// server auth
ctx_.set_verify_mode(boost::asio::ssl::context::verify_peer, ec);
Expand Down Expand Up @@ -223,7 +223,7 @@ void IFMapChannel::ReconnectPreparationInMainThr() {
IFMAP_PEER_DEBUG(IFMapServerConnection,
"Retrying connection to Ifmap-server.", "");
} else {
IFMAP_PEER_DEBUG(IFMapServerConnection,
IFMAP_PEER_NOTICE(IFMapServerConnection,
"Connection to Ifmap-server went down.", "");
}

Expand Down Expand Up @@ -315,7 +315,7 @@ void IFMapChannel::DoConnectInMainThr(bool is_ssrc) {
set_start_stale_entries_cleanup(true);
}
set_connection_status(UP);
IFMAP_PEER_DEBUG(IFMapServerConnection,
IFMAP_PEER_NOTICE(IFMapServerConnection,
"Connection to Ifmap-server came up.", "");
}
}
Expand Down Expand Up @@ -446,7 +446,7 @@ int IFMapChannel::ExtractPubSessionId() {
size_t start_pos = (pos + str.length());
size_t pub_id_len = pos1 - pos - str.length();
pub_id_ = reply_str.substr(start_pos, pub_id_len);
IFMAP_PEER_DEBUG(IFMapServerConnection, "Pub-id is", pub_id_);
IFMAP_PEER_NOTICE(IFMapServerConnection, "Pub-id is", pub_id_);

// Get the session-id returned by the server
// EG: session-id="2077221532-423634091-1596075545-1209811427"
Expand All @@ -473,7 +473,7 @@ int IFMapChannel::ExtractPubSessionId() {
start_pos = (pos + str.length());
size_t session_id_len = pos1 - pos - str.length();
session_id_ = reply_str.substr(start_pos, session_id_len);
IFMAP_PEER_DEBUG(IFMapServerConnection, "Session-id is", session_id_);
IFMAP_PEER_NOTICE(IFMapServerConnection, "Session-id is", session_id_);

return 0;
}
Expand Down Expand Up @@ -723,7 +723,7 @@ void IFMapChannel::StopStaleEntriesCleanupTimer() {

// Called in the context of the main thread.
bool IFMapChannel::ProcessStaleEntriesTimeout() {
IFMAP_PEER_WARN(IFMapServerConnection,
IFMAP_PEER_NOTICE(IFMapServerConnection,
integerToString(UTCTimestampUsec()/1000 -
stale_entries_cleanup_timer_started_at_us_),
"millisecond stale cleanup timer fired");
Expand Down Expand Up @@ -763,7 +763,7 @@ void IFMapChannel::StopEndOfRibTimer() {

// Called in the context of the main thread.
bool IFMapChannel::ProcessEndOfRibTimeout() {
IFMAP_PEER_DEBUG(IFMapServerConnection,
IFMAP_PEER_NOTICE(IFMapServerConnection,
integerToString(UTCTimestampUsec()/1000 -
end_of_rib_timer_started_at_us_),
"millisecond end of rib timer fired");
Expand Down
6 changes: 3 additions & 3 deletions src/ifmap/client/peer_server_finder.cc
Expand Up @@ -152,7 +152,7 @@ void PeerIFMapServerFinder::ProcPeerIFMapDSResp(
// available peer and trigger a new connection to this new peer.
PeerIFMapServerInfo srv_info;
bool valid = GetBestPeer(&srv_info);
IFMAP_PEER_DEBUG(IFMapBestPeer, "DSResp", srv_info.ToString(), valid);
IFMAP_PEER_NOTICE(IFMapBestPeer, "DSResp", srv_info.ToString(), valid);
if (valid) {
if (!old_peer.IsSamePeer(srv_info)) {
if (init_done_) {
Expand Down Expand Up @@ -199,7 +199,7 @@ bool PeerIFMapServerFinder::PeerDown() {
tbb::mutex::scoped_lock lock(ds_mutex_);
// Get the 'next' best available peer
bool is_valid = GetBestPeer(&srv_info);
IFMAP_PEER_DEBUG(IFMapBestPeer, "PeerDown", srv_info.ToString(), is_valid);
IFMAP_PEER_NOTICE(IFMapBestPeer, "PeerDown", srv_info.ToString(), is_valid);
if (is_valid) {
ifmap_manager_->ResetConnection(srv_info.host, srv_info.port);
}
Expand All @@ -219,7 +219,7 @@ void PeerIFMapServerFinder::RetrieveStaticHostPort(const std::string& url) {
static_peer_.port = url.substr(pos2 + 1);
// setting in_use field is not needed

IFMAP_PEER_DEBUG(IFMapUrlInfo, "IFMap server host is", static_peer_.host,
IFMAP_PEER_NOTICE(IFMapUrlInfo, "IFMap server host is", static_peer_.host,
"and port is", static_peer_.port);
}

Expand Down
20 changes: 20 additions & 0 deletions src/ifmap/ifmap_log.h
Expand Up @@ -149,4 +149,24 @@ do { \
IFMAP_SM_TRACE(obj##Trace, __VA_ARGS__); \
} while(0)

#define IFMAP_NOTICE_LOG(obj, category, ...) \
do { \
if (!LoggingDisabled()) { \
obj::Send(g_vns_constants.CategoryNames.find(category)->second, \
SandeshLevel::SYS_NOTICE, __FILE__, __LINE__, ##__VA_ARGS__); \
} \
} while(0)

#define IFMAP_PEER_NOTICE(obj, ...) \
do { \
IFMAP_NOTICE_LOG(obj, Category::IFMAP_PEER, __VA_ARGS__); \
IFMAP_PEER_TRACE(obj##Trace, __VA_ARGS__); \
} while(0)

#define IFMAP_NOTICE(obj, ...) \
do { \
IFMAP_NOTICE_LOG(obj, Category::IFMAP, __VA_ARGS__); \
IFMAP_TRACE(obj##Trace, __VA_ARGS__); \
} while(0)

#endif // __IFMAP_LOG_H__
2 changes: 1 addition & 1 deletion src/ifmap/ifmap_server.cc
Expand Up @@ -118,7 +118,7 @@ class IFMapServer::IFMapStaleEntriesCleaner : public Task {
}
}
}
IFMAP_WARN(IFMapStaleEntriesCleanerInfo, curr_seq_num, nodes_deleted,
IFMAP_NOTICE(IFMapStaleEntriesCleanerInfo, curr_seq_num, nodes_deleted,
nodes_changed, links_deleted, objects_deleted);

return true;
Expand Down

0 comments on commit 7233049

Please sign in to comment.