Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnsdist: Add a new, optional, YAML-based configuration format #14969

Draft
wants to merge 110 commits into
base: master
Choose a base branch
from

Conversation

rgacogne
Copy link
Member

Short description

This PR adds support for a new, optional, YAML-based configuration format. At this point this is still a work in progress!
If the configuration file passed to dnsdist via the -C command-line switch ends in .yml, it is assumed to be in the new YAML format, and an attempt to load a Lua configuration file with the same name but the .lua will be done before loading the YAML configuration. If the names ends in .lua, there will also be an attempt to find a file with the same name but ending in .yml. Otherwise the existing Lua configuration format is assumed.
The parsing of the YAML configuration is done using Serde, so Rust is a requirement for the new configuration format, but the existing Lua configuration format is still supported so DNSdist can still be built without Rust. This might change in the future.

A fair amount of the new code is generated, based on a (YAML) description of the configuration settings, including the selectors and actions composing DNSdist's rules. Lua bindings for a fair amount of supported selectors and actions are now generated as well. My plan is to generate Lua bindings for most of the settings as well in the future.

The documentation of the new configuration format is not yet done, although a fair amount can already be generated from the definitions of settings, selectors and actions.
I have added several regression tests using the new configuration format, so for now it's possible to look at these to get a fell of the new format.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

The previous method didn't account for TCP workers for backends.
This works around a linker issue with the default linker (bfd) and
LTO when building against a static Rust library.
@coveralls
Copy link

coveralls commented Dec 13, 2024

Pull Request Test Coverage Report for Build 12356327481

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2792 of 4824 (57.88%) changed or added relevant lines in 31 files are covered.
  • 6673 unchanged lines in 105 files lost coverage.
  • Overall coverage decreased (-4.6%) to 60.184%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pdns/dnsdistdist/dnsdist-lua-ffi.cc 6 7 85.71%
pdns/libssl.cc 0 1 0.0%
pdns/dnsdistdist/dnsdist-dnsparser.cc 15 17 88.24%
pdns/qtype.cc 5 7 71.43%
pdns/dnsdistdist/dnsdist-lua.cc 11 14 78.57%
pdns/dnsdistdist/dnsdist-lua-actions-generated.cc 71 75 94.67%
pdns/dnsdistdist/dnsdist-dynblocks.cc 6 11 54.55%
pdns/dnsdistdist/dnsdist-lua-actions.cc 59 64 92.19%
pdns/dnsdistdist/dnsdist-actions-factories-generated.cc 69 75 92.0%
pdns/dnsdistdist/dnsdist-lua-response-actions-generated.cc 33 39 84.62%
Files with Coverage Reduction New Missed Lines %
pdns/webserver.hh 1 69.16%
pdns/packethandler.cc 1 72.57%
pdns/dnsdistdist/test-dnsdisttcp_cc.cc 1 94.98%
pdns/recursordist/sortlist.hh 1 75.0%
pdns/pollmplexer.cc 1 83.66%
pdns/dnstap.cc 2 68.82%
ext/probds/murmur3.cc 2 88.24%
pdns/sstuff.hh 2 53.78%
pdns/distributor.hh 2 51.86%
pdns/statnode.cc 2 47.55%
Totals Coverage Status
Change from base Build 12316427950: -4.6%
Covered Lines: 116190
Relevant Lines: 160313

💛 - Coveralls

name = boost::uuids::to_string(uuid);
}

auto [it, inserted] = s_registeredTypesMap.lock()->try_emplace(name, entry);

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable it is not used.
return true;
}

static std::shared_ptr<DownstreamState> createBackendFromConfiguration(const dnsdist::rust::settings::BackendsConfiguration& config, bool configCheck)

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 129 lines.
}
#endif /* defined(HAVE_YAML_CONFIGURATION) */

bool loadConfigurationFromFile(const std::string& fileName, bool isClient, bool configCheck)

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 437 lines.
auto globalConfig = dnsdist::rust::settings::from_yaml_string(data);

if (!globalConfig.console.listen_address.empty()) {
const auto& consoleConf = globalConfig.console;

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable consoleConf is not used.
/* entries are ordered from least recently seen to more recently
seen, as soon as we see one that has not expired yet, we are
done */
lookedAt++;

Check notice

Code scanning / CodeQL

For loop variable changed in body Note

Loop counters should not be modified in the body of the
loop
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants