Skip to content

KAFKA-6195: Resolve DNS aliases in bootstrap.server#4485

Merged
rajinisivaram merged 36 commits intoapache:trunkfrom
lepolac:KAFKA-6195
Oct 13, 2018
Merged

KAFKA-6195: Resolve DNS aliases in bootstrap.server#4485
rajinisivaram merged 36 commits intoapache:trunkfrom
lepolac:KAFKA-6195

Conversation

@lepolac
Copy link
Copy Markdown

@lepolac lepolac commented Jan 29, 2018

Change described in KIP-235
https://cwiki.apache.org/confluence/display/KAFKA/KIP-235%3A+Add+DNS+alias+support+for+secured+connection

I license the work to the Apache Kafka project under the project's open source license.

import org.apache.kafka.clients.KafkaClient;
import org.apache.kafka.clients.Metadata;
import org.apache.kafka.clients.NetworkClient;
import org.apache.kafka.clients.*;
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.

I don't think we want star imports.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed.

this.metadata = metadata;
List<InetSocketAddress> addresses = ClientUtils.parseAndValidateAddresses(
config.getList(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG));
List<InetSocketAddress> addresses = ClientUtils.parseAndValidateAddresses(config.getList(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG),config.getString(CommonClientConfigs.CLIENT_DNS_LOOKUP));
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.

This line is too long. We need the linebreaks back here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed.

checkWithoutLookup("127.0.0.1:8000");
checkWithoutLookup("mydomain.com:8080");
checkWithoutLookup("[::1]:8000");
checkWithoutLookup("[2001:db8:85a3:8d3:1319:8a2e:370:7348]:1234", "mydomain.com:10000");
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.

Some day, mydomain.com will be changed and all of this will break. Additionally, this prevents people from running the unit tests without network connectivity. Our unit tests shouldn't have this dependency on an external network resource.

We should be able to figure out what the IP address is for localhost and go from there.

If we want to validate a non-localhost address as well, we can use the standard "example.com" (See https://en.wikipedia.org/wiki/Example.com )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point. I was merely following what was already in place.
Would we want to address this now or could the feature be merged as is and I can take a stab at having something better for this test next week?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated the tests.

Comment thread clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java
Comment thread clients/src/main/java/org/apache/kafka/clients/ClientDnsLookup.java
jonathanskrzypek and others added 6 commits June 7, 2018 13:22
KAFKA-6195: Add new parameter to toggle reverse dns lookup

KAFKA-6195: Remove specific handling for SSL.

Reverse DNS lookup performed regardless of the SecurityProtocol used if bootstrap.reverse.dns.lookup is set to true.

KAFKA-6195 introduce enum to drive dns lookup behaviour

Remove star import

adding apache license header
Comment thread clients/src/main/java/org/apache/kafka/clients/ClientUtils.java
+ "servers (you may want more than one, though, in case a server is down).";

public static final String CLIENT_DNS_LOOKUP = "client.dns.lookup";
public static final String CLIENT_DNS_LOOKUP_DOC = "Drives whether the client performs DNS lookups on entries of bootstrap.servers";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would phrase this as "To enable client DNS lookups on bootstrap.servers"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

changed.

@harshach
Copy link
Copy Markdown

harshach commented Jul 9, 2018

@lepolac overall looks good to me. Left a minor nit and there are few un-addressed comments from previous reviewers. Can you address these and rebase your commits into single one.

@lepolac
Copy link
Copy Markdown
Author

lepolac commented Aug 14, 2018

@harshach I'm a bit struggling to rebase the commits, started from a fresh directory, cloned my fork, checked out my KAFKA-6195 branch. Then added official repo as a remote, fetched it. A git merge-base KAFKA-6195 kafka/trunk gives me hash b5da5f8, but doing a rebase -i on that hash doesn't show me anything to pick.
Basically followed https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request

Any ideas ?

@harshach
Copy link
Copy Markdown

@lepolac sorry didn't see your comment. The approach I usually go for is to update the trunk branch in my fork and merge with my JIRA branch.

git pull apache trunk
git checkout KAFKA-6195
git merge trunk

@lepolac
Copy link
Copy Markdown
Author

lepolac commented Aug 24, 2018

@harshach Ok, managed to push, hopefully this looks ok ?

@omkreddy
Copy link
Copy Markdown
Contributor

retest this please

Comment thread clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java Outdated
@omkreddy
Copy link
Copy Markdown
Contributor

@lepolac couple of compilation errors are coming. You can run ./gradlew clean :clients:test
to compile and test the changes.

/Users/mkumar/workspace/kafka/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:401: error: constructor RecordAccumulator in class RecordAccumulator cannot be applied to given types;
            this.accumulator = new RecordAccumulator(logContext,
                               ^
  required: LogContext,int,CompressionType,long,long,long,Metrics,String,Time,ApiVersions,TransactionManager,BufferPool
  found: LogContext,Integer,long,CompressionType,Integer,long,int,Metrics,String,Time,ApiVersions,TransactionManager,BufferPool
  reason: actual and formal argument lists differ in length

/Users/mkumar/workspace/kafka/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:414: error: method parseAndValidateAddresses in class ClientUtils cannot be applied to given types;
            List<InetSocketAddress> addresses = ClientUtils.parseAndValidateAddresses(config.getList(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG));
                                                           ^
  required: List<String>,String
  found: List<String>
  reason: actual and formal argument lists differ in length

@rajinisivaram
Copy link
Copy Markdown
Contributor

@lepolac @edoardocomar @mimaison I have reviewed this as well as PR #4987. If we can the config naming consistent today, address review comments and get clean builds today, then we can merge both to 2.1.0 and trunk.

@rajinisivaram
Copy link
Copy Markdown
Contributor

@lepolac I will merge PR #4987 once its PR builds complete. Can you rebase this on top of that, once the build is ready? Thank you!

@rajinisivaram
Copy link
Copy Markdown
Contributor

@lepolac I have merged the other PR. Can you rebase this one please?

@lepolac
Copy link
Copy Markdown
Author

lepolac commented Oct 11, 2018

Ok, looks like ClientDnsLookup from the other KIP was put in another module and uses other value lookup methods, will merge this.

@rajinisivaram
Copy link
Copy Markdown
Contributor

@lepolac I think ClientDnsLookup should be in org.apache.kafka.clients as you have in this PR. I will check if @edoardocomar or @mimaison can fix that.

@lepolac
Copy link
Copy Markdown
Author

lepolac commented Oct 12, 2018

Probably faster for us to change on this PR I think as other one is already merged

@rajinisivaram
Copy link
Copy Markdown
Contributor

@lepolac @adammilnesmith There are PR build failures, can you take a look?

Copy link
Copy Markdown
Contributor

@rajinisivaram rajinisivaram left a comment

Choose a reason for hiding this comment

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

@lepolac Thanks for the updates, looks good. Left some minor comments. I think I can merge this once they are addressed.

String resolvedCanonicalName = inetAddress.getCanonicalHostName();
InetSocketAddress address = new InetSocketAddress(resolvedCanonicalName, port);
if (address.isUnresolved()) {
log.warn("Couldn't resolve server {} from {} as DNS resolution of the canonical hostname failed for {}", url, CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, host);
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.

Can we include resolvedCanonicalName in the warning?

@@ -162,7 +168,9 @@ public class AdminClientConfig extends AbstractConfig {
.define(CommonClientConfigs.CLIENT_DNS_LOOKUP_CONFIG,
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.

Change from CommonClientConfigs.CLIENT_DNS_LOOKUP_CONFIG to CLIENT_DNS_LOOKUP_CONFIG?

ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
ClientDnsLookup.RESOLVE_CANONICAL_BOOTSTRAP_SERVERS_ONLY.toString()),
Importance.MEDIUM,
CommonClientConfigs.CLIENT_DNS_LOOKUP_DOC)
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.

Change from CommonClientConfigs.CLIENT_DNS_LOOKUP_DOC to CLIENT_DNS_LOOKUP_DOC?

Comment thread clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java Outdated
new ConfigDef.NonNullValidator(),
Importance.HIGH,
CommonClientConfigs.BOOTSTRAP_SERVERS_DOC)
.define(CommonClientConfigs.CLIENT_DNS_LOOKUP_CONFIG,
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.

Change CommonClientConfigs.CLIENT_DNS_LOOKUP_CONFIG to CLIENT_DNS_LOOKUP_CONFIG?

import scala.collection.mutable.HashMap
import scala.collection.{Set, mutable}
import org.apache.kafka.common.config.ClientDnsLookup
import org.apache.kafka.clients.ClientDnsLookup
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.

There is a wildcard import in this class for org.apache.kafka.clients, so this import is not required.

import collection.JavaConverters._
import scala.collection.{concurrent, immutable}
import org.apache.kafka.common.config.ClientDnsLookup
import org.apache.kafka.clients.ClientDnsLookup
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.

There is a wildcard import in this class for org.apache.kafka.clients, so this import is not required.


import scala.collection.JavaConverters._
import org.apache.kafka.common.config.ClientDnsLookup
import org.apache.kafka.clients.ClientDnsLookup
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.

There is a wildcard import in this class for org.apache.kafka.clients, so this import is not required.


import scala.collection.JavaConverters._
import org.apache.kafka.common.config.ClientDnsLookup
import org.apache.kafka.clients.ClientDnsLookup
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.

There is a wildcard import in this class for org.apache.kafka.clients, so this import is not required.

import org.apache.kafka.common.Cluster;
import org.apache.kafka.common.Node;
import org.apache.kafka.common.config.ClientDnsLookup;
import org.apache.kafka.clients.ClientDnsLookup;
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.

Can we just move this above alongside client imports?

@lepolac
Copy link
Copy Markdown
Author

lepolac commented Oct 13, 2018

Looks like one of the build fails with unrelated tests ?
The other one passes

Copy link
Copy Markdown
Contributor

@rajinisivaram rajinisivaram left a comment

Choose a reason for hiding this comment

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

@lepolac Thanks for the updates, LGTM. I will make some minor updates to reorganize imports where package changed and merge the PR.

@rajinisivaram rajinisivaram merged commit a947fe8 into apache:trunk Oct 13, 2018
rajinisivaram pushed a commit that referenced this pull request Oct 13, 2018
Adds `client.dns.lookup=resolve_canonical_bootstrap_servers_only` option to perform full dns resolution of bootstrap addresses

Reviewers: Colin Patrick McCabe <[email protected]>, Sriharsha Chintalapani <[email protected]>, Edoardo Comar <[email protected]>, Mickael Maison <[email protected]>, Manikumar Reddy <[email protected]>, Rajini Sivaram <[email protected]>
@rajinisivaram
Copy link
Copy Markdown
Contributor

Merged to trunk and 2.1.

@lepolac
Copy link
Copy Markdown
Author

lepolac commented Oct 13, 2018

Thanks !!

pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…#4485)

Adds `client.dns.lookup=resolve_canonical_bootstrap_servers_only` option to perform full dns resolution of bootstrap addresses

Reviewers: Colin Patrick McCabe <[email protected]>, Sriharsha Chintalapani <[email protected]>, Edoardo Comar <[email protected]>, Mickael Maison <[email protected]>, Manikumar Reddy <[email protected]>, Rajini Sivaram <[email protected]>
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.

9 participants