Skip to content

MINOR: Handle case where connector status endpoints returns 404#6176

Merged
mjsax merged 5 commits intoapache:trunkfrom
wicknicks:connect-integration-connector-status
Jan 21, 2019
Merged

MINOR: Handle case where connector status endpoints returns 404#6176
mjsax merged 5 commits intoapache:trunkfrom
wicknicks:connect-integration-connector-status

Conversation

@wicknicks
Copy link
Copy Markdown
Contributor

@wicknicks wicknicks commented Jan 19, 2019

The integration test framework for Connect provides a org.apache.kafka.connect.util.clusters.EmbeddedConnectCluster#connectorStatus method that checks the status of a Connector via the REST endpoint and deserializes the response into a ConnectorStateInfo object. If the connector creation request has just been finished, and task creation delayed for some reason (for example, rebalancing is ongoing), the REST API returns a 404 on the connectors/{connectorName}/status endpoint, and causes the test to fail with the exception:

[2019-01-19 03:47:59,289] (Test worker) ERROR Could not read connector state (org.apache.kafka.connect.util.clusters.EmbeddedConnectCluster:178)
java.io.FileNotFoundException: http://localhost:38625/connectors/simple-conn/status
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1909)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
	at org.apache.kafka.connect.util.clusters.EmbeddedConnectCluster.executeGet(EmbeddedConnectCluster.java:223)
	at org.apache.kafka.connect.util.clusters.EmbeddedConnectCluster.connectorStatus(EmbeddedConnectCluster.java:176)
	at org.apache.kafka.connect.integration.ExampleConnectIntegrationTest.lambda$testProduceConsumeConnector$1(ExampleConnectIntegrationTest.java:117)
	at org.apache.kafka.test.TestUtils.waitForCondition(TestUtils.java:355)
	at org.apache.kafka.test.TestUtils.waitForCondition(TestUtils.java:342)
	at org.apache.kafka.connect.integration.ExampleConnectIntegrationTest.testProduceConsumeConnector(ExampleConnectIntegrationTest.java:117)

This fix handles the 404 case instead of simply re-throwing the Exception.

Signed-off-by: Arjun Satish arjun@confluent.io

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@wicknicks wicknicks force-pushed the connect-integration-connector-status branch 2 times, most recently from c1ed1c8 to 14f01d5 Compare January 19, 2019 20:58
@wicknicks
Copy link
Copy Markdown
Contributor Author

@rhauch @mageshn @rayokota can you please take a look at this PR? Thanks in advance.

@wicknicks wicknicks force-pushed the connect-integration-connector-status branch from 4358167 to 6c4b917 Compare January 19, 2019 21:36
Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

A few questions.

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.

Do all the places where this method is called handle null? There is no JavaDoc that explains/summarizes what will be returned, so maybe add that JavaDoc. The AbstractHerder never returns null and instead throws a NotFoundException when the named connector is not found.

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 removed this check, and documented the behavior. thanks!

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.

Nit: why use an else block here? The if block always returns, so really no else is needed, right?

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.

The exception can contain any arbitrary status code. We are only calling the else block if the status code is not 404.

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 appears in the two connector integration tests in AK's codebase. Should TestUtils or EmbeddedConnectCluster have a method that does this?

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.

Would it also be helpful here to catch any exceptions that might be thrown by the condition?

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.

TestUtils is in the clients module. And adding it to EmbeddedConnectCluster seemed incorrect as this method depends on checking that depended on ConnectorHandle. I've moved it to an IntegrationTestUtils class. Let me know what you think.

@wicknicks wicknicks force-pushed the connect-integration-connector-status branch 2 times, most recently from 86b0161 to 4419f19 Compare January 19, 2019 23:30
Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

One more minor suggestion just to ward off a potentially alarming log message. Otherwise, looks good.

@wicknicks wicknicks force-pushed the connect-integration-connector-status branch from fcc6917 to a148226 Compare January 19, 2019 23:58
@wicknicks
Copy link
Copy Markdown
Contributor Author

@rhauch I've addressed your comments. There is a bit of code duplication in the tests but we can address that in a follow up PR.

Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

Looks great, @wicknicks! Thanks for fixing this and addressing my nits and questions.

@wicknicks
Copy link
Copy Markdown
Contributor Author

retest this please.

Signed-off-by: Arjun Satish <arjun@confluent.io>
Signed-off-by: Arjun Satish <arjun@confluent.io>
Signed-off-by: Arjun Satish <arjun@confluent.io>
@wicknicks wicknicks force-pushed the connect-integration-connector-status branch from a148226 to a6e21fc Compare January 20, 2019 08:25
@wicknicks
Copy link
Copy Markdown
Contributor Author

retest this please.

…swallows exceptions

Signed-off-by: Arjun Satish <arjun@confluent.io>
@wicknicks wicknicks force-pushed the connect-integration-connector-status branch from a6e21fc to f700c80 Compare January 20, 2019 09:58
@wicknicks
Copy link
Copy Markdown
Contributor Author

retest this please

Signed-off-by: Arjun Satish <arjun@confluent.io>
@wicknicks
Copy link
Copy Markdown
Contributor Author

retest this please

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Jan 20, 2019

Ok. One last try. If it fails again, I will merge with one green build.

Retest this please.

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Jan 21, 2019

We got some green builds before. Merging as-is.

@mjsax mjsax merged commit dc935c4 into apache:trunk Jan 21, 2019
@wicknicks
Copy link
Copy Markdown
Contributor Author

Thanks a lot, @mjsax!

mjsax pushed a commit that referenced this pull request Jan 21, 2019
Reviewers: Randall Hauch <randall@confluent.io>, Matthias J. Sax <matthias@confluent.io>
mjsax pushed a commit that referenced this pull request Jan 21, 2019
Reviewers: Randall Hauch <randall@confluent.io>, Matthias J. Sax <matthias@confluent.io>
@mjsax
Copy link
Copy Markdown
Member

mjsax commented Jan 21, 2019

Merged to trunk and cherry-picked to 2.1 and 2.0 branches.

abbccdda pushed a commit to abbccdda/kafka that referenced this pull request Jan 24, 2019
…he#6176)

Reviewers: Randall Hauch <randall@confluent.io>, Matthias J. Sax <matthias@confluent.io>
jarekr pushed a commit to confluentinc/kafka that referenced this pull request Apr 18, 2019
* ak/trunk:
  MINOR: fix race condition in KafkaStreamsTest (apache#6185)
  KAFKA-4850: Enable bloomfilters (apache#6012)
  MINOR: ducker-ak: add down -f, avoid using a terminal in ducker test
  KAFKA-5117: Stop resolving externalized configs in Connect REST API
  MINOR: Cleanup handling of mixed transactional/idempotent records (apache#6172)
  KAFKA-7844: Use regular subproject for generator to fix *All targets (apache#6182)
  Fix Documentation for cleanup.policy is out of date (apache#6181)
  MINOR: increase timeouts for KafkaStreamsTest (apache#6178)
  MINOR: Rejoin split ssl principal mapping rules (apache#6099)
  MINOR: Handle case where connector status endpoints returns 404 (apache#6176)
  MINOR: Remove unused imports, exceptions, and values (apache#6117)
  KAFKA-3522: Add internal RecordConverter interface (apache#6150)
  Fix Javadoc of KafkaConsumer (apache#6155)
  KAFKA-6455: Extend CacheFlushListener to forward timestamp (apache#6147)
  MINOR: Log partition info when creating new request batch in controller (apache#6145)
  KAFKA-7652: Part I; Fix SessionStore's findSession(single-key) (apache#6134)
  MINOR: Remove the InvalidTopicException handling in InternalTopicManager (apache#6167)
  [KAFKA-7024] Rocksdb state directory should be created before opening the DB (apache#6138)
  MINOR:: Fix typos (apache#6079)
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…he#6176)

Reviewers: Randall Hauch <randall@confluent.io>, Matthias J. Sax <matthias@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants