Skip to content

[improve][client] Add a way to configure which DNS use#21227

Merged
tisonkun merged 5 commits into
apache:masterfrom
diegosalvi:client-builder-dns-servers
Oct 24, 2023
Merged

[improve][client] Add a way to configure which DNS use#21227
tisonkun merged 5 commits into
apache:masterfrom
diegosalvi:client-builder-dns-servers

Conversation

@diegosalvi

@diegosalvi diegosalvi commented Sep 21, 2023

Copy link
Copy Markdown
Contributor

This closes #21226

Motivation

Currently is not possibile to configure one or more dns servers that will be used by the client to resolve hostnames.

Modifications

Added an optional configuration ClientConfigurationData.dnsServerAddresses to allow to configure custom DNSs. It not provided or empty will default to the existing behaviour.
Handled the new conf in ConnectionPool.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Added unit test on ClientBuilderImplTest with configuration of both good or wrong dns servers
  • Added integration test on PulsarClientImplTest with a custom configured dns servers list
  • Added unit test on ConfigurationDataUtilsTest about the new configuration loading

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions Bot added the doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. label Sep 21, 2023

@nodece nodece left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed

@diegosalvi diegosalvi requested a review from nodece September 26, 2023 08:31
@diegosalvi diegosalvi requested a review from nodece September 26, 2023 12:53
@diegosalvi diegosalvi force-pushed the client-builder-dns-servers branch from b8d2756 to 48b6c0c Compare September 27, 2023 13:54
@diegosalvi

Copy link
Copy Markdown
Contributor Author

Rebased on synced fork

@diegosalvi

Copy link
Copy Markdown
Contributor Author

Last review issue has been addressed

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lgtm

@nodece

nodece commented Oct 3, 2023

Copy link
Copy Markdown
Member

/pulsarbot rerun-failure-checks

@diegosalvi

Copy link
Copy Markdown
Contributor Author

Fails org.apache.pulsar.common.nar.NarUnpackerTest.shouldExtractFilesOnceInDifferentProcess
Could it be flaky?

@nodece

nodece commented Oct 5, 2023

Copy link
Copy Markdown
Member

@diegosalvi Could you rebase your codebase?

@lhotari

lhotari commented Oct 5, 2023

Copy link
Copy Markdown
Member

@diegosalvi Could you please provide more context of the use case? The reason why I'm asking is that I don't currently see why the Pulsar client should have a different DNS server configured apart from the rest of the application and the OS where the app is running.

@lhotari

lhotari commented Oct 5, 2023

Copy link
Copy Markdown
Member

Fails org.apache.pulsar.common.nar.NarUnpackerTest.shouldExtractFilesOnceInDifferentProcess Could it be flaky?

Yes, it's flaky. reported as #21291

@diegosalvi

Copy link
Copy Markdown
Contributor Author

@lhotari currently we are using Pulsar in a production environment. In such environment we have need to use different dns for the server machine (configured by standard resolvconf et simillia) and java processes. For many java cases we directly do lookups on dns with different libraries (so we don't use java discovered dnses) but we can't do the same for Pulsar.
To be able to configure which dns use can be useful depending on environments to specialize them

@diegosalvi diegosalvi force-pushed the client-builder-dns-servers branch from 1b57ce5 to 9e2bc1a Compare October 5, 2023 16:05
@diegosalvi

Copy link
Copy Markdown
Contributor Author

@nodece Rebased

@lhotari

lhotari commented Oct 5, 2023

Copy link
Copy Markdown
Member

@lhotari currently we are using Pulsar in a production environment. In such environment we have need to use different dns for the server machine (configured by standard resolvconf et simillia) and java processes. For many java cases we directly do lookups on dns with different libraries (so we don't use java discovered dnses) but we can't do the same for Pulsar.
To be able to configure which dns use can be useful depending on environments to specialize them

@diegosalvi for future documentation purposes, would you be able to share more details and a common reference? Is it a split DNS setup where you have an internal DNS separate from an external DNS ? Would you configure the Pulsar client to use the internal DNS server?

@diegosalvi

Copy link
Copy Markdown
Contributor Author

@lhotari Yes, something along the line. DNS for Pulsar are "internal" "applicative" ones leaving the host machine with a different set of dns (via resolv.conf etc etc) and other "external" DNS queried directly by java processes when in need to resolve "public" names.

@diegosalvi

Copy link
Copy Markdown
Contributor Author

Still fails for NarUnpackerTest

@lhotari

lhotari commented Oct 9, 2023

Copy link
Copy Markdown
Member

Still fails for NarUnpackerTest

@diegosalvi This flaky NarUnpackerTest has been fixed. You can get the fix to this PR by rebasing on or merging origin/master.

@diegosalvi diegosalvi force-pushed the client-builder-dns-servers branch from 9e2bc1a to 53f5241 Compare October 9, 2023 14:03
@diegosalvi

Copy link
Copy Markdown
Contributor Author

Rebased again

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #21227 (53f5241) into master (8438e43) will increase coverage by 36.37%.
Report is 6 commits behind head on master.
The diff coverage is 80.64%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #21227       +/-   ##
=============================================
+ Coverage     36.84%   73.22%   +36.37%     
- Complexity    12229    32529    +20300     
=============================================
  Files          1699     1888      +189     
  Lines        130559   140257     +9698     
  Branches      14264    15445     +1181     
=============================================
+ Hits          48106   102703    +54597     
+ Misses        76121    29457    -46664     
- Partials       6332     8097     +1765     
Flag Coverage Δ
inttests 24.19% <45.16%> (-0.14%) ⬇️
systests 24.73% <41.93%> (+<0.01%) ⬆️
unittests 72.53% <80.64%> (+40.58%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...va/org/apache/pulsar/broker/service/ServerCnx.java 71.76% <100.00%> (+30.24%) ⬆️
...n/java/org/apache/pulsar/broker/service/Topic.java 36.36% <ø> (+28.03%) ⬆️
...lsar/client/impl/conf/ClientConfigurationData.java 96.69% <100.00%> (+8.45%) ⬆️
...g/apache/pulsar/client/impl/ClientBuilderImpl.java 85.98% <83.33%> (+39.62%) ⬆️
.../org/apache/pulsar/client/impl/ConnectionPool.java 75.96% <66.66%> (+14.01%) ⬆️
...ava/org/apache/pulsar/broker/service/Producer.java 82.64% <75.00%> (+20.21%) ⬆️

... and 1444 files with indirect coverage changes

@nodece nodece left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR adds a public method to ClientBuilder.java, I'm not sure if PIP is required.

LGTM

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with this proposal and since it adds a new public API, I suppose a PIP is required to create, while it should be very straight forward and we can quickly reach a consensus.

@diegosalvi what do you think? You can refer to this page for sending a PIP.

cc @codelipenghui @Technoboy-

@tisonkun

Copy link
Copy Markdown
Member

Pending for merging as PIP-305 #21352 merged.

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@tisonkun tisonkun merged commit 25c662d into apache:master Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a configurable DNS server list

6 participants