Skip to content

KAFKA-6394: Add a check to prevent misconfiguration of advertised listeners#4897

Merged
hachikuji merged 4 commits intoapache:trunkfrom
omkreddy:KAFKA-6394-ADVERTISED
May 11, 2018
Merged

KAFKA-6394: Add a check to prevent misconfiguration of advertised listeners#4897
hachikuji merged 4 commits intoapache:trunkfrom
omkreddy:KAFKA-6394-ADVERTISED

Conversation

@omkreddy
Copy link
Copy Markdown
Contributor

No description provided.

@omkreddy
Copy link
Copy Markdown
Contributor Author

@hachikuji Please take a look when you get a chance. Thanks.

Copy link
Copy Markdown
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

Thanks @omkreddy. Should we also validate advertised listeners after a dynamic config change?

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.

Should we check port as well? I think using the same host is pretty common, especially for development.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can check port also. Updated the code.

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 wonder if we should check config.advertisedListeners instead? I guess you are expecting that we would fail to bind if the listener was incorrectly specified?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking we want this check only if advertised.listeners configured. but it makes sense to check if listener was incorrectly specified. updated the code

@omkreddy omkreddy force-pushed the KAFKA-6394-ADVERTISED branch 3 times, most recently from b2c688a to 368aedf Compare April 23, 2018 16:39
@omkreddy omkreddy force-pushed the KAFKA-6394-ADVERTISED branch from 368aedf to 28bf632 Compare April 23, 2018 16:58
@omkreddy
Copy link
Copy Markdown
Contributor Author

@hachikuji Thanks for the review. yes, we can validate advertised listeners after a dynamic config change. Updated the code. Pls take a look.

throw new ConfigException(s"Advertised listener must be specified for inter-broker listener ${newConfig.interBrokerListenerName}")

val endPoints = newConfig.advertisedListeners.map(e => s"${e.host}:${e.port}")
server.zkClient.getAllBrokersInCluster.filter(_.id != newConfig.brokerId).foreach(broker => {
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.

Not sure it's worthwhile given how rarely the listeners would be updated in practice, but I guess we could also use the metadata cache?

Otherwise, it would be nice to factor out the common logic between this and KafkaServer. Like maybe a method in AdminUtils?

Copy link
Copy Markdown
Contributor Author

@omkreddy omkreddy Apr 27, 2018

Choose a reason for hiding this comment

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

@hachikuji I am also not strongly inclined to add this check in DynamicConfig validation phase. DynamicListenerConfig.reconfigure method fails if there any misconfigured listeners. here:
https://github.com/omkreddy/kafka/blob/28bf632dc791ec42077b8ab19aad7583a44975d4/core/src/main/scala/kafka/server/DynamicBrokerConfig.scala#L804

If there are no concerns, I want to drop this check from DynamicBrokerConfig. validateReconfiguration

@omkreddy
Copy link
Copy Markdown
Contributor Author

omkreddy commented Apr 30, 2018

@hachikuji reverted changes related to dynamic configs. Pls take a look.

@omkreddy
Copy link
Copy Markdown
Contributor Author

omkreddy commented May 9, 2018

@hachikuji pinging for review. Thanks.

Copy link
Copy Markdown
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the patch. Note I made a trivial tweak to have the error message display the common endpoints.

Copy link
Copy Markdown
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

@omkreddy Sorry, just one more small comment.

import org.scalatest.Assertions.intercept

class KafkaConfigTest {
class KafkaConfigTest extends ZooKeeperTestHarness {
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.

It's a little annoying that we had to do this just for the one test case. Maybe we could add a KafkaServerTest since KafkaServer is where the check was added?

@omkreddy omkreddy force-pushed the KAFKA-6394-ADVERTISED branch from 77ef269 to e0d7441 Compare May 11, 2018 02:48
@omkreddy
Copy link
Copy Markdown
Contributor Author

@hachikuji Thanks for the review. Updated the PR.

@hachikuji
Copy link
Copy Markdown
Contributor

LGTM, thanks @omkreddy

@hachikuji hachikuji merged commit ec7ba32 into apache:trunk May 11, 2018
ying-zheng pushed a commit to ying-zheng/kafka that referenced this pull request Jul 6, 2018
…teners (apache#4897)

Do not allow server startup if one of its configured advertised listeners has already been registered by another broker.
@jeckhart
Copy link
Copy Markdown

Sorry to resurrect a zombie thread, but this broke a common pattern we use for our healthcheck listeners. Typically our healthcheck listeners advertise only 127.0.0.1:9094 and the sidecar process runs locally and communicates over localhost. Now, with this change, the broker won't start because the listener is already registered.

@w32-blaster
Copy link
Copy Markdown

Just came here after debugging the same issue @jeckhart (assuming you got it from the gruntwork module). Can we make an exception for localhost or 127.0.0.1?

@jeckhart
Copy link
Copy Markdown

Yes, I got it from the Gruntwork module. I think that proposal works for me.

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