Skip to content

Commit

Permalink
Issue: debug value specified in config file(contrail-vrouter-agent.c…
Browse files Browse the repository at this point in the history
…onf)

    is not honoured properly. If debug keyword is specified in the file,
    irrespective of the value, debug flags at other classes(Agent, KSyncDebug) are set.
    Fix: Definition of debug program option is modified as a name/value pair
    and flag is set properly by retrieving the value.
    closes-bug: #1561005

    Change-Id: Ibc837537fac857157ba5c54030a679e4bf6ed011

Change-Id: Ia7fe9061c62fcd96b4582c266007a2d0508567e8
  • Loading branch information
ravi-bk committed Apr 22, 2016
1 parent 1f37616 commit 29aaa56
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/vnsw/agent/contrail-vrouter-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# agent_mode=

# Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable)
# debug=0
debug=0

# Aging time for flow-records in seconds
# flow_cache_timeout=0
Expand Down
14 changes: 3 additions & 11 deletions src/vnsw/agent/init/agent_param.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,7 @@ void AgentParam::ParseDefaultSection() {
log_local_ = false;
}

if (optional<bool> debug_opt =
tree_.get_optional<bool>("DEFAULT.debug")) {
debug_ = true;
} else {
debug_ = false;
}

GetValueFromTree<bool>(debug_, "DEFAULT.debug");
GetValueFromTree<bool>(use_syslog_, "DEFAULT.use_syslog");
if (!GetValueFromTree<string>(syslog_facility_, "DEFAULT.syslog_facility")) {
syslog_facility_ = "LOG_LOCAL0";
Expand Down Expand Up @@ -722,15 +716,13 @@ void AgentParam::ParseDefaultSectionArguments
GetValueFromTree<long>(log_file_size_, "DEFAULT.log_file_size");
GetOptValue<string>(var_map, log_level_, "DEFAULT.log_level");
GetOptValue<string>(var_map, syslog_facility_, "DEFAULT.syslog_facility");
GetOptValue<bool>(var_map, debug_, "DEFAULT.debug");
if (var_map.count("DEFAULT.use_syslog")) {
use_syslog_ = true;
}
if (var_map.count("DEFAULT.log_local")) {
log_local_ = true;
}
if (var_map.count("DEFAULT.debug")) {
debug_ = true;
}
if (var_map.count("DEFAULT.log_flow")) {
log_flow_ = true;
}
Expand Down Expand Up @@ -1285,7 +1277,7 @@ AgentParam::AgentParam(bool enable_flow_options,
("DEFAULT.collectors",
opt::value<std::vector<std::string> >()->multitoken(),
"Collector server list")
("DEFAULT.debug", "Enable debug logging")
("DEFAULT.debug", opt::value<bool>(), "Enable / Disable debug logging")
("DEFAULT.flow_cache_timeout",
opt::value<uint16_t>()->default_value(Agent::kDefaultFlowCacheTimeout),
"Flow aging time in seconds")
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/init/test/cfg-default1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ server=127.0.0.1
agent_mode=tsn

# Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable)
debug=1
debug=0

# Aging time for flow-records in seconds
flow_cache_timeout=60
Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/init/test/test_agent_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ TEST_F(FlowTest, Agent_Conf_file_1) {
EXPECT_STREQ(param.agent_base_dir().c_str(), "/var/lib/contrail");
EXPECT_EQ(param.subnet_hosts_resolvable(), true);
EXPECT_EQ(param.pkt0_tx_buffer_count(), 2000);
EXPECT_TRUE(param.debug());
}

TEST_F(FlowTest, Agent_Conf_file_2) {
Expand Down Expand Up @@ -316,6 +317,7 @@ TEST_F(FlowTest, Default_Cmdline_arg1) {
EXPECT_STREQ(param.log_level().c_str(), "SYS_ERR");
EXPECT_TRUE(param.isXenMode());
EXPECT_EQ(param.agent_mode(), AgentParam::TSN_AGENT);
EXPECT_FALSE(param.debug());
}

/* Some command line args have default values. If user has not passed these
Expand Down

0 comments on commit 29aaa56

Please sign in to comment.