Skip to content

Commit 448b921

Browse files
committed
Added debug log output for derecho.cfg options
It's really hard to notice if Derecho fails to load derecho.cfg because it will silently fall back to all-default values for the config options. To help users debug this, I added a debug-level log statement in the Group constructor that prints out all the actual config options that are in memory, and changed the fallback default log level to "debug" instead of "info" so those value will get printed out even if derecho.cfg fails to load. I also added a console print statement to print a warning if none of derecho.cfg, derecho_node.cfg, or command-line parameters are present; the Conf constructor can't use Logger so console printing is the only way to notify the user that something might be wrong.
1 parent 2247e45 commit 448b921

4 files changed

Lines changed: 21 additions & 11 deletions

File tree

include/derecho/conf/conf.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class Conf {
2727
//String constants for config options
2828
static constexpr const char* DERECHO_CONTACT_IP = "DERECHO/contact_ip";
2929
static constexpr const char* DERECHO_CONTACT_PORT = "DERECHO/contact_port";
30-
static constexpr const char* DERECHO_LEADER_EXTERNAL_PORT = "DERECHO/leader_external_port";
3130
static constexpr const char* DERECHO_RESTART_LEADERS = "DERECHO/restart_leaders";
3231
static constexpr const char* DERECHO_RESTART_LEADER_PORTS = "DERECHO/restart_leader_ports";
3332
static constexpr const char* DERECHO_LOCAL_ID = "DERECHO/local_id";
@@ -85,7 +84,6 @@ class Conf {
8584
// [DERECHO]
8685
{DERECHO_CONTACT_IP, "127.0.0.1"},
8786
{DERECHO_CONTACT_PORT, "23580"},
88-
{DERECHO_LEADER_EXTERNAL_PORT, "32645"},
8987
{DERECHO_RESTART_LEADERS, "127.0.0.1"},
9088
{DERECHO_RESTART_LEADER_PORTS, "23580"},
9189
{DERECHO_LOCAL_ID, "0"},
@@ -126,7 +124,7 @@ class Conf {
126124
{PERS_PRIVATE_KEY_FILE, "private_key.pem"},
127125
// [LOGGER]
128126
{LOGGER_DEFAULT_LOG_NAME, "derecho_debug"},
129-
{LOGGER_DEFAULT_LOG_LEVEL, "info"},
127+
{LOGGER_DEFAULT_LOG_LEVEL, "debug"},
130128
{LOGGER_LOG_TO_TERMINAL, "true"},
131129
{LOGGER_LOG_FILE_DEPTH, "3"}};
132130

@@ -206,6 +204,8 @@ class Conf {
206204
const bool hasCustomizedKey(const std::string& key) const {
207205
return (this->config.find(key) != this->config.end());
208206
}
207+
/** Returns a string representation of all configuration options in the table, for debugging purposes. */
208+
std::string getDebugString() const;
209209
/**
210210
* Initialize the singleton from the command line and the configuration files.
211211
* The command line has higher priority than the configuration files, and the

include/derecho/core/detail/group_impl.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include "derecho_internal.hpp"
1111
#include "make_kind_map.hpp"
1212

13-
#include <spdlog/async.h>
14-
#include <spdlog/sinks/rotating_file_sink.h>
15-
#include <spdlog/sinks/stdout_color_sinks.h>
16-
1713
namespace derecho {
1814

1915
template <typename SubgroupType>
@@ -28,7 +24,7 @@ template <typename SubgroupType>
2824
uint32_t _Group::get_subgroup_max_payload_size(uint32_t subgroup_num) {
2925
if (auto gptr = dynamic_cast<GroupProjection<SubgroupType>*>(this)) {
3026
return gptr->get_subgroup_max_payload_size(subgroup_num);
31-
} else
27+
} else
3228
throw derecho_exception("Error: this top-level group contains no subgroups for the selected type.");
3329
}
3430

@@ -205,6 +201,7 @@ Group<ReplicatedTypes...>::Group(const UserMessageCallbacks& callbacks,
205201
#else
206202
factories(make_kind_map<Factory>(factories...)) {
207203
#endif
204+
dbg_default_debug("Starting with configuration options:\n{}", Conf::get()->getDebugString());
208205
bool in_total_restart = view_manager.first_init();
209206
// State transfer must complete before an initial view can commit, and must retry if the view is aborted
210207
bool initial_view_confirmed = false;

src/conf/conf.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <sys/stat.h>
88
#include <unistd.h>
99
#include <stdexcept>
10+
#include <sstream>
1011

1112
namespace derecho {
1213

@@ -31,7 +32,6 @@ struct option Conf::long_options[] = {
3132
// [DERECHO]
3233
MAKE_LONG_OPT_ENTRY(DERECHO_CONTACT_IP),
3334
MAKE_LONG_OPT_ENTRY(DERECHO_CONTACT_PORT),
34-
MAKE_LONG_OPT_ENTRY(DERECHO_LEADER_EXTERNAL_PORT),
3535
MAKE_LONG_OPT_ENTRY(DERECHO_RESTART_LEADERS),
3636
MAKE_LONG_OPT_ENTRY(DERECHO_RESTART_LEADER_PORTS),
3737
MAKE_LONG_OPT_ENTRY(DERECHO_LOCAL_ID),
@@ -182,6 +182,7 @@ Conf::Conf(int argc, char* argv[], std::optional<std::string> group_conf_file,
182182
loadFromFile(node_conf_file.value());
183183
}
184184
// 2 - load configuration from the command line
185+
bool command_options_present = false;
185186
int c;
186187
while(1) {
187188
int option_index = 0;
@@ -194,6 +195,7 @@ Conf::Conf(int argc, char* argv[], std::optional<std::string> group_conf_file,
194195
switch(c) {
195196
case 0:
196197
this->config[long_options[option_index].name] = optarg;
198+
command_options_present = true;
197199
break;
198200

199201
case '?':
@@ -203,6 +205,10 @@ Conf::Conf(int argc, char* argv[], std::optional<std::string> group_conf_file,
203205
std::cerr << "ignore unknown commandline code:" << c << std::endl;
204206
}
205207
}
208+
// 3 - warn the user if no options were loaded, since this probably indicates an error
209+
if(!group_conf_file && !node_conf_file && !command_options_present) {
210+
std::cerr << "Warning: derecho.cfg and derecho_node.cfg not found, and no command-line options specified. Falling back to all default configuration options." << std::endl;
211+
}
206212
}
207213

208214
// should we force the user to call Conf::initialize() by throw an expcetion
@@ -247,6 +253,13 @@ void Conf::loadExtraFile(const std::string& default_file_name, const char* env_v
247253
singleton->loadFromFile(real_file_name);
248254
}
249255

256+
std::string Conf::getDebugString() const {
257+
std::stringstream debug_str;
258+
for(const auto& kv_pair : config) {
259+
debug_str << "\t" << kv_pair.first << " = " << kv_pair.second << std::endl;
260+
}
261+
return debug_str.str();
262+
}
250263

251264
const std::string& getConfString(const std::string& key) {
252265
return Conf::get()->getString(key);

src/core/git_version.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace derecho {
1313
const int MAJOR_VERSION = 2;
1414
const int MINOR_VERSION = 4;
1515
const int PATCH_VERSION = 1;
16-
const int COMMITS_AHEAD_OF_VERSION = 2;
16+
const int COMMITS_AHEAD_OF_VERSION = 4;
1717
const char* VERSION_STRING = "2.4.1";
18-
const char* VERSION_STRING_PLUS_COMMITS = "2.4.1+2";
18+
const char* VERSION_STRING_PLUS_COMMITS = "2.4.1+4";
1919

2020
}

0 commit comments

Comments
 (0)