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

feat(bootstrap): support multiple upstreams #782

Merged
merged 5 commits into from
Jan 18, 2023

Conversation

ThinkChaos
Copy link
Collaborator

If more than one upstream is configured, they are raced via a ParallelBestResolver.

Other improvements:

  • feat(bootstrap): support IP only encrypted DNS
    Also make tcp+udp upstreams use any IPs provided.
  • feat: always prefetch upstream IPs to avoid stalling user queries
    Otherwise, a request to blocky could end up waiting for 2 DNS requests:
    1. lookup the DNS server IP
    2. forward the user request to the server looked-up in 1
  • feat: stack log prefixes to differentiate between log emitters
    The goal is to be able to tell apart logs from difference sources, such as bootstrap.parallel_best_resolver and parallel_best_resolver.

Also includes #781 so the lint passes here.

Fixes #760.

Copy link
Collaborator Author

@ThinkChaos ThinkChaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend reviewing commit by commit. Everything should be relatively simple that way.

Comment on lines +71 to +75
if existingPrefix, ok := logger.Data[prefixField]; ok {
prefix = fmt.Sprintf("%s.%s", existingPrefix, prefix)
}

return logger.WithField(prefixField, prefix)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked into it, but this might break the dashboards or whatever else depends on the prefix being exactly the name of the resolver.

resolver/bootstrap_test.go Outdated Show resolved Hide resolved
@0xERR0R 0xERR0R added the 🔨 enhancement New feature or request label Dec 9, 2022
@0xERR0R 0xERR0R added this to the 0.21 milestone Dec 9, 2022
Copy link
Owner

@0xERR0R 0xERR0R left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I added one test case to check the conversion of the new YAML structure (list of bootstrap entries).

Could you please change the documentation (configuration.md and config.yaml in docs folder)?

I think it would also make sense to write some e2e tests to test the bootstrap resolution, but this is not a part of this PR/issue. I'll take a look, how it can be achieved.

@ThinkChaos ThinkChaos force-pushed the feat/parallel-bootstrap branch from d403ae5 to 1e14e06 Compare December 15, 2022 01:19
Comment on lines +73 to +76
if cachingCfg.MinCachingTime == 0 {
// Set a min time in case the user didn't to avoid prefetching too often
cachingCfg.MinCachingTime = config.Duration(time.Hour)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this some more, I noticed that caching.minTime has no default.
Since with this MR, the caching resolver is always enabled with prefetching as part of the Bootstrap, this can cause a lot of churn for not much gains.
I noticed because the domain s3.amazonaws.com used by the list https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt I have in my test config has a TTL of 3, and was being prefetched every 10 seconds.

I added a default of 1h here, only if the user hasn't specified anything (or they put 0). Let me know if you think I should revert this and we should just trust the TTLs.

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Base: 93.29% // Head: 92.97% // Decreases project coverage by -0.32% ⚠️

Coverage data is based on head (9e9a23c) compared to base (fb00905).
Patch coverage: 84.93% of modified lines in pull request are covered.

Additional details and impacted files
@@               Coverage Diff               @@
##           development     #782      +/-   ##
===============================================
- Coverage        93.29%   92.97%   -0.32%     
===============================================
  Files               42       42              
  Lines             4845     4943      +98     
===============================================
+ Hits              4520     4596      +76     
- Misses             257      276      +19     
- Partials            68       71       +3     
Impacted Files Coverage Δ
resolver/resolver.go 100.00% <ø> (ø)
config/config.go 88.40% <58.62%> (-1.52%) ⬇️
resolver/caching_resolver.go 96.46% <83.33%> (-1.42%) ⬇️
resolver/bootstrap.go 92.55% <86.48%> (-3.77%) ⬇️
resolver/blocking_resolver.go 98.14% <100.00%> (ø)
resolver/client_names_resolver.go 95.61% <100.00%> (ø)
resolver/conditional_upstream_resolver.go 100.00% <100.00%> (ø)
resolver/custom_dns_resolver.go 100.00% <100.00%> (ø)
resolver/hosts_file_resolver.go 100.00% <100.00%> (ø)
resolver/parallel_best_resolver.go 100.00% <100.00%> (ø)
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ThinkChaos
Copy link
Collaborator Author

Added the docs, rebased and cleaned up the commits. This should be all good now if you approve!

ThinkChaos and others added 5 commits January 18, 2023 09:58
If more than one upstream is configured, they are raced via
a `ParallelBestResolver`.
Also make `tcp+udp` upstreams use any IPs provided.
The goal is to be able to tell apart logs from difference sources, such
as `bootstrap.parallel_best_resolver` and `parallel_best_resolver`.
Otherwise, a request to blocky could end up waiting for 2 DNS requests:
  1. lookup the DNS server IP
  2. forward the user request to the server looked-up in 1
@ThinkChaos ThinkChaos force-pushed the feat/parallel-bootstrap branch from 1e14e06 to 9e9a23c Compare January 18, 2023 15:32
@ThinkChaos ThinkChaos merged commit 65137b4 into 0xERR0R:development Jan 18, 2023
@ThinkChaos ThinkChaos deleted the feat/parallel-bootstrap branch January 21, 2023 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use multiple upstreams for bootstrapDns.
2 participants