Skip to content

Commit

Permalink
utils: config_file: fix handling of workdir,W in the YAML file
Browse files Browse the repository at this point in the history
Option names given in db/config.cc are handled for the command line by passing
them to boost::program_options, and by YAML by comparing them with YAML
keys.
boost::program_options has logic for understanding the
long_name,short_name syntax, so for a "workdir,W" option both --workdir and -W
worked, as intended. But our YAML config parsing doesn't have this logic
and expected "workdir,W" verbatim, which is obviously not intended. Fix that.

Fixes scylladb#7478
Fixes scylladb#9500
Fixes scylladb#11503

Closes scylladb#11506
  • Loading branch information
michoecho authored and kbr-scylla committed Sep 9, 2022
1 parent dba595d commit af7ace3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/config_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,13 @@ utils::config_type::to_json(const void* value) const {

bool
utils::config_file::config_src::matches(std::string_view name) const {
if (_name == name) {
// The below line provides support for option names in the "long_name,short_name" format,
// such as "workdir,W". We only want the long name ("workdir") to be used in the YAML.
// But since at some point (due to a bug) the YAML config parser expected the silly
// double form ("workdir,W") instead, we support both for backward compatibility.
std::string_view long_name = _name.substr(0, _name.find_first_of(','));

if (_name == name || long_name == name) {
return true;
}
if (!_alias.empty() && _alias == name) {
Expand Down

0 comments on commit af7ace3

Please sign in to comment.