Skip to content

Commit

Permalink
Process cassandra db configuration upon SIGUSR1 in control-node
Browse files Browse the repository at this point in the history
During ISSU, V2 control-node needs to be notified to read the cassandra
db again as rabbitmq v2 which sends update notifications would not have
been up for a small time window.

Currently, DB is re-read only if the contrail-control.conf is modified
(wrt cassandra db server list, user name, password, etc.). We can do the
same re-read process upon SIGUSR1 signal as well. This can come in handy
in case control-node is stuck ever with stale config data as well. (as a
work around to restarting the control-node process itself)

This fix was verified by systest.

TODO: Unit tests for this entire config-db re-read is still a pending
action item.

Change-Id: Ib8b9e39a572cfb688d95e81756372a1f33964d8f
Closes-Bug: 1779186
  • Loading branch information
ananth-at-camphor-networks committed Jun 28, 2018
1 parent d211c8d commit a1b3a99
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/control-node/main.cc
Expand Up @@ -205,12 +205,14 @@ static void ControlNodeGetProcessStateCb(const BgpServer *bgp_server,
}
}

void ReConfigSignalHandler(const boost::system::error_code &error, int sig) {
void ReConfigSignalHandler(const boost::system::error_code &error, int sig,
bool force_reinit) {
if (error) {
LOG(ERROR, "SIGHUP handler ERROR: " << error);
return;
}
options.ParseReConfig();
LOG(WARN, "Received signal " << sig << " inside ReConfigSignalHandler()");
options.ParseReConfig(force_reinit);
}

int main(int argc, char *argv[]) {
Expand All @@ -221,9 +223,13 @@ int main(int argc, char *argv[]) {

srand(unsigned(time(NULL)));
std::vector<Signal::SignalHandler> sighup_handlers = boost::assign::list_of
(boost::bind(&ReConfigSignalHandler, _1, _2));
(boost::bind(&ReConfigSignalHandler, _1, _2, false));
std::vector<Signal::SignalHandler> sigusr1_handlers = boost::assign::list_of
(boost::bind(&ReConfigSignalHandler, _1, _2, true));
Signal::SignalCallbackMap smap = boost::assign::map_list_of
(SIGHUP, sighup_handlers);
(SIGHUP, sighup_handlers)
(SIGUSR1, sigusr1_handlers)
;
Signal signal(&evm, smap);

ControlNode::SetProgramName(argv[0]);
Expand Down
5 changes: 3 additions & 2 deletions src/control-node/options.cc
Expand Up @@ -314,7 +314,7 @@ bool Options::Process(int argc, char *argv[],
return true;
}

void Options::ParseReConfig() {
void Options::ParseReConfig(bool force_reinit) {
// ReParse the filtered config params
opt::variables_map var_map;
ifstream config_file_in;
Expand Down Expand Up @@ -343,7 +343,8 @@ void Options::ParseReConfig() {

uint32_t old_config_chksum = configdb_chksum_;
ParseConfigOptions(var_map);
if ((old_config_chksum != configdb_chksum_) && config_client_manager_) {
if ((force_reinit || old_config_chksum != configdb_chksum_) &&
config_client_manager_) {
config_client_manager_->ReinitConfigClient(configdb_options());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/control-node/options.h
Expand Up @@ -81,7 +81,7 @@ class Options {
}
const SandeshConfig &sandesh_config() const { return sandesh_config_; }

void ParseReConfig();
void ParseReConfig(bool force_reinit);

void set_config_client_manager(ConfigClientManager *mgr) {
config_client_manager_ = mgr;
Expand Down

0 comments on commit a1b3a99

Please sign in to comment.