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

refactor(config): allow more configuration for upstreams #1086

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

ThinkChaos
Copy link
Collaborator

Rename the upstream option to upstreams.groups so we can have more upstreams options.

Rename the `upstream` option to `upstreams.groups` so we can have
more `upstreams` options.
@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.11% ⚠️

Comparison is base (d3fc1bc) 93.80% compared to head (32287e6) 93.69%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1086      +/-   ##
==========================================
- Coverage   93.80%   93.69%   -0.11%     
==========================================
  Files          66       66              
  Lines        5341     5345       +4     
==========================================
- Hits         5010     5008       -2     
- Misses        258      263       +5     
- Partials       73       74       +1     
Files Changed Coverage Δ
config/config.go 78.20% <100.00%> (+0.18%) ⬆️
config/upstreams.go 100.00% <100.00%> (ø)
resolver/bootstrap.go 92.66% <100.00%> (-2.76%) ⬇️
resolver/conditional_upstream_resolver.go 100.00% <100.00%> (ø)
resolver/parallel_best_resolver.go 100.00% <100.00%> (ø)
resolver/upstream_resolver.go 89.13% <100.00%> (ø)
server/server.go 79.03% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@kwitsch kwitsch left a comment

Choose a reason for hiding this comment

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

👍

@DerRockWolf
Copy link
Contributor

Thanks for already working on the config part.

What do you think of the idea with both "global" upstream and group specific settings?
Instead of the group name being the list of upstream servers they would be under the "resolvers" key. Alternatively we could get rid of the "global" upstream settings and only have group specific setting. What do you think?

example for both global and group specific configuration:

upstreams:
  timeout: 5s
  upstreamStrategy: parallel_best
  otherSettingUsedByAllGroups: xyz
  groups:
    <name>:
      timeout: 5s
      upstreamStrategy: parallel_best
      resolvers:
        - 1.1.1.1
        - 8.8.8.8

example for only group specific configuration:

upstreams:
  groups:
    <name>:
      timeout: 5s
      upstreamStrategy: parallel_best
      resolvers:
        - 1.1.1.1
        - 8.8.8.8

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.

Looks very good, thanks!

@@ -489,6 +490,8 @@ func unmarshalConfig(data []byte, cfg *Config) error {

func (cfg *Config) migrate(logger *logrus.Entry) bool {
usesDepredOpts := Migrate(logger, "", cfg.Deprecated, map[string]Migrator{
"upstream": Move(To("upstreams.groups", &cfg.Upstreams)),
Copy link
Owner

Choose a reason for hiding this comment

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

👍

10.43.8.67/28:
- 1.1.1.1
- 9.9.9.9
upstreams:
Copy link
Owner

Choose a reason for hiding this comment

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

👍

@0xERR0R
Copy link
Owner

0xERR0R commented Aug 1, 2023

Thanks for already working on the config part.

What do you think of the idea with both "global" upstream and group specific settings? Instead of the group name being the list of upstream servers they would be under the "resolvers" key. Alternatively we could get rid of the "global" upstream settings and only have group specific setting. What do you think?

example for both global and group specific configuration:

upstreams:
  timeout: 5s
  upstreamStrategy: parallel_best
  otherSettingUsedByAllGroups: xyz
  groups:
    <name>:
      timeout: 5s
      upstreamStrategy: parallel_best
      resolvers:
        - 1.1.1.1
        - 8.8.8.8

example for only group specific configuration:

upstreams:
  groups:
    <name>:
      timeout: 5s
      upstreamStrategy: parallel_best
      resolvers:
        - 1.1.1.1
        - 8.8.8.8

IMHO, one global configuration is enough. Configuration per group makes it too over-complicated and is useful only for very special edge cases.

@ThinkChaos
Copy link
Collaborator Author

We can always add per group config later and be back compatible with a custom UnmarshalYAML.

@ThinkChaos ThinkChaos merged commit 639fba5 into 0xERR0R:main Aug 1, 2023
@ThinkChaos ThinkChaos deleted the refactor/upstreams-config branch August 1, 2023 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants