RedPillAnalytics / gradle-confluent

Apache License 2.0
22 stars 10 forks source link

Connector creation and drop queries fail #120

Closed bhanurz closed 2 years ago

bhanurz commented 2 years ago

Describe the bug Connector creation and drop queries fail. Sample query:

CREATE SOURCE CONNECTOR mock_connector WITH (
    "connector.class"='org.apache.kafka.connect.tools.MockConnector',
    "topics.regex"='mock-topic');

Connector creation fails with following error:

> Task :pipelineExecute FAILED
Caching disabled for task ':pipelineExecute' because:
  Build cache is disabled
Task ':pipelineExecute' is not up-to-date because:
  Task.upToDateWhen is false.
DROP CONNECTOR mock_connector;
:pipelineExecute (Thread[Execution worker for ':',5,main]) completed. Took 0.606 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':pipelineExecute'.
> java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

Note that it tries to drop the connector even if it does not exist.

Drop connector results in following error:

> Task :pipelineExecute FAILED
Caching disabled for task ':pipelineExecute' because:
  Build cache is disabled
Task ':pipelineExecute' is not up-to-date because:
  Task.upToDateWhen is false.
DROP CONNECTOR mock_connector;
:pipelineExecute (Thread[Execution worker for ':',5,main]) completed. Took 0.217 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':pipelineExecute'.
> java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

To Reproduce Steps to reproduce the behavior:

  1. Create a connector KSQL query.
  2. Run query with gradle-confluent.
  3. Query execution fails.

Expected behaviour Connector queries should execute successfully.

Additional context Following fix was done to validate the issue: https://github.com/RedPillAnalytics/gradle-confluent/pull/119

In getSourceDescription, following is used to return status of connector:

return response.body.status

However, it should be as follows because an array is return by KSQL:

return response.body[0].status

Using .status on an ArrayList causes it to return a list which is non null: [null]. This subsequently leads to the condition add to check object existence to pass.

Other failures are due to no command ID present for connector query executions so logic related to command ID should not be executed for connectors.

bhanurz commented 2 years ago

@stewartbryson Hello, hope you are well. Please check the above when possible and let me know if provided fix addresses the issue. Once acknowledged from your end, I will work on any refactoring and tests required in the PR. Thank you.

stewartbryson commented 2 years ago

I merged the PR and a new release was generated. If works, can you close the issue?

Thanks so much for your contribution.

bhanurz commented 2 years ago

@stewartbryson Thanks for quick turn around on providing a release. Tested on my end, working as expected. Closing the issue.