Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implemention of KLIP-13 #4099

Conversation

alex-dukhno
Copy link
Contributor

@alex-dukhno alex-dukhno commented Dec 10, 2019

Description

Implementation of KLIP-13 Introduce KSQL command to print connect worker properties to the console

(LIST|SHOW) PROPERTIES command is extended to print embedded connect worker properties

Testing done

N/A
Do we need integration test that touch file system to read connect worker properties file, or it would be better hide the fact that its properties come from file system?
Edited:
This is how it looks in the terminal on my machine

ksql> SHOW PROPERTIES;

 Property                                               | Default override | Effective Value
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 bootstrap.servers                                      | SESSION          | localhost:9092
 config.storage.replication.factor                      | SESSION          | 1
 config.storage.topic                                   | SESSION          | ksql-connect-configs
 group.id                                               | SESSION          | ksql-connect-cluster
 internal.key.converter                                 | SESSION          | org.apache.kafka.connect.json.JsonConverter
 internal.key.converter.schemas.enable                  | SESSION          | false
 internal.value.converter                               | SESSION          | org.apache.kafka.connect.json.JsonConverter
 key.converter                                          | SESSION          | io.confluent.connect.avro.AvroConverter
 key.converter.schema.registry.url                      | SESSION          | http://localhost:8081
 ksql.access.validator.enable                           |                  | auto
 ksql.connect.url                                       |                  | http://localhost:8083
 ksql.connect.worker.config                             | SERVER           | config/connect.properties
 ksql.extension.dir                                     |                  | ext
 ksql.insert.into.values.enabled                        |                  | true
 ksql.internal.topic.min.insync.replicas                |                  | 1
 ksql.internal.topic.replicas                           |                  | 1
 ksql.metric.reporters                                  |                  |
 ksql.metrics.extension                                 |                  | NULL
 ksql.metrics.tags.custom                               |                  |
 ksql.output.topic.name.prefix                          |                  |
 ksql.persistence.wrap.single.values                    |                  | true
 ksql.persistent.prefix                                 |                  | query_
 ksql.pull.queries.enable                               |                  | true
 ksql.query.persistent.active.limit                     |                  | 2147483647
 ksql.query.pull.routing.timeout.ms                     |                  | 30000
 ksql.query.pull.skip.access.validator                  |                  | false
 ksql.query.pull.streamsstore.rebalancing.timeout.ms    |                  | 10000
 ksql.schema.registry.url                               |                  | http://localhost:8081
 ksql.security.extension.class                          |                  | NULL
 ksql.service.id                                        |                  | default_
 ksql.sink.window.change.log.additional.retention       |                  | 1000000
 ksql.streams.application.server                        | SERVER           | http://localhost:8088
 ksql.streams.bootstrap.servers                         | SERVER           | localhost:9092
 ksql.streams.cache.max.bytes.buffering                 | SERVER           | 10000000
 ksql.streams.commit.interval.ms                        | SERVER           | 2000
 ksql.streams.default.deserialization.exception.handler | SERVER           | io.confluent.ksql.errors.LogMetricAndContinueExceptionHandler
 ksql.streams.default.production.exception.handler      | SERVER           | io.confluent.ksql.errors.ProductionExceptionHandlerUtil$LogAndFailProductionExceptionHandler
 ksql.streams.num.stream.threads                        | SERVER           | 4
 ksql.streams.topology.optimization                     | SERVER           | all
 ksql.transient.prefix                                  |                  | transient_
 ksql.udf.collect.metrics                               |                  | false
 ksql.udf.enable.security.manager                       |                  | true
 ksql.udfs.enabled                                      |                  | true
 offset.storage.replication.factor                      | SESSION          | 1
 offset.storage.topic                                   | SESSION          | ksql-connect-offsets
 status.storage.replication.factor                      | SESSION          | 1
 status.storage.topic                                   | SESSION          | ksql-connect-statuses
 value.converter                                        | SESSION          | io.confluent.connect.avro.AvroConverter
 value.converter.schema.registry.url                    | SESSION          | http://localhost:8081
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Documentation

I couldn't find the documentation part that should be changed. Is there another repo for that part?

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@alex-dukhno alex-dukhno requested a review from a team as a code owner December 10, 2019 15:21
@ghost
Copy link

ghost commented Dec 10, 2019

@confluentinc It looks like @alex-dukhno just signed our Contributor License Agreement. 👍

Always at your service,

clabot

Copy link
Contributor

@agavra agavra left a comment

Choose a reason for hiding this comment

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

Hello @alex-dukhno - this looks pretty good to me! I don't think any documentation or integration tests need to be added to this, but if you could show the output of a LIST PROPERTIES on a server that has a connect worker running (copy and paste it into the testing done section) that would help confirm that everything works as expected.

@agavra agavra self-assigned this Dec 10, 2019
@agavra agavra requested a review from a team December 10, 2019 17:21
@alex-dukhno
Copy link
Contributor Author

@agavra I've updated PR description.

Copy link
Contributor

@agavra agavra left a comment

Choose a reason for hiding this comment

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

I didn't think about this when reviewing the KLIP (so thanks for bearing with me!), but looking at this now I just noticed that there are some overlaps (i.e. both connect and ksql specify bootstrap.servers)...

I think to resolve this we need to introduce "SCOPE" in this PR. It shouldn't be too tough, we can change PropertiesList to have an internal class:

@JsonIgnorePropertes(ignoreUnknown = true)
static class Property {
  @JsonCreator
  public Property(
    @JsonProperty("property") final String property,
    @JsonProperty("scope") final String scope
}

And then the properties field can be a Map<Property, ?> instead of Map<String, ?> and can now have duplicate property names under different scope. Similarly, we would change PropertiesListTableBuilder to include the extra column.

@alex-dukhno
Copy link
Contributor Author

alex-dukhno commented Dec 11, 2019

@agavra I have added scope column to LIST PROPERTIES command, now it looks like this in my terminal:

ksql> show properties;

 Property                                               | Scope                   | Default override | Effective Value
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 bootstrap.servers                                      | EMBEDDED CONNECT WORKER | SESSION          | localhost:9092
 config.storage.replication.factor                      | EMBEDDED CONNECT WORKER | SESSION          | 1
 config.storage.topic                                   | EMBEDDED CONNECT WORKER | SESSION          | ksql-connect-configs
 group.id                                               | EMBEDDED CONNECT WORKER | SESSION          | ksql-connect-cluster
 internal.key.converter                                 | EMBEDDED CONNECT WORKER | SESSION          | org.apache.kafka.connect.json.JsonConverter
 internal.key.converter.schemas.enable                  | EMBEDDED CONNECT WORKER | SESSION          | false
 internal.value.converter                               | EMBEDDED CONNECT WORKER | SESSION          | org.apache.kafka.connect.json.JsonConverter
 key.converter                                          | EMBEDDED CONNECT WORKER | SESSION          | io.confluent.connect.avro.AvroConverter
 key.converter.schema.registry.url                      | EMBEDDED CONNECT WORKER | SESSION          | http://localhost:8081
 ksql.access.validator.enable                           | KSQL                    |                  | auto
 ksql.connect.url                                       | KSQL                    |                  | http://localhost:8083
 ksql.connect.worker.config                             | KSQL                    | SERVER           | config/connect.properties
 ksql.extension.dir                                     | KSQL                    |                  | ext
 ksql.insert.into.values.enabled                        | KSQL                    |                  | true
 ksql.internal.topic.min.insync.replicas                | KSQL                    |                  | 1
 ksql.internal.topic.replicas                           | KSQL                    |                  | 1
 ksql.metric.reporters                                  | KSQL                    |                  |
 ksql.metrics.extension                                 | KSQL                    |                  | NULL
 ksql.metrics.tags.custom                               | KSQL                    |                  |
 ksql.output.topic.name.prefix                          | KSQL                    |                  |
 ksql.persistence.wrap.single.values                    | KSQL                    |                  | true
 ksql.persistent.prefix                                 | KSQL                    |                  | query_
 ksql.pull.queries.enable                               | KSQL                    |                  | true
 ksql.query.persistent.active.limit                     | KSQL                    |                  | 2147483647
 ksql.query.pull.routing.timeout.ms                     | KSQL                    |                  | 30000
 ksql.query.pull.skip.access.validator                  | KSQL                    |                  | false
 ksql.query.pull.streamsstore.rebalancing.timeout.ms    | KSQL                    |                  | 10000
 ksql.schema.registry.url                               | KSQL                    |                  | http://localhost:8081
 ksql.security.extension.class                          | KSQL                    |                  | NULL
 ksql.service.id                                        | KSQL                    |                  | default_
 ksql.sink.window.change.log.additional.retention       | KSQL                    |                  | 1000000
 ksql.streams.application.server                        | KSQL                    | SERVER           | http://localhost:8088
 ksql.streams.bootstrap.servers                         | KSQL                    | SERVER           | localhost:9092
 ksql.streams.cache.max.bytes.buffering                 | KSQL                    | SERVER           | 10000000
 ksql.streams.commit.interval.ms                        | KSQL                    | SERVER           | 2000
 ksql.streams.default.deserialization.exception.handler | KSQL                    | SERVER           | io.confluent.ksql.errors.LogMetricAndContinueExceptionHandler
 ksql.streams.default.production.exception.handler      | KSQL                    | SERVER           | io.confluent.ksql.errors.ProductionExceptionHandlerUtil$LogAndFailProductionExceptionHandler
 ksql.streams.num.stream.threads                        | KSQL                    | SERVER           | 4
 ksql.streams.topology.optimization                     | KSQL                    | SERVER           | all
 ksql.transient.prefix                                  | KSQL                    |                  | transient_
 ksql.udf.collect.metrics                               | KSQL                    |                  | false
 ksql.udf.enable.security.manager                       | KSQL                    |                  | true
 ksql.udfs.enabled                                      | KSQL                    |                  | true
 offset.storage.replication.factor                      | EMBEDDED CONNECT WORKER | SESSION          | 1
 offset.storage.topic                                   | EMBEDDED CONNECT WORKER | SESSION          | ksql-connect-offsets
 status.storage.replication.factor                      | EMBEDDED CONNECT WORKER | SESSION          | 1
 status.storage.topic                                   | EMBEDDED CONNECT WORKER | SESSION          | ksql-connect-statuses
 value.converter                                        | EMBEDDED CONNECT WORKER | SESSION          | io.confluent.connect.avro.AvroConverter
 value.converter.schema.registry.url                    | EMBEDDED CONNECT WORKER | SESSION          | http://localhost:8081
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Just let me know if I did something silly 😛. Especially, tests fixes feels like "ad-hoc" solutions.

+ " k1 | KSQL | SERVER | 1 \n"
+ " k2 | KSQL | SERVER | v2 \n"
+ " k3 | KSQL | SERVER | true \n"
+ "-------------------------------------------------------\n"));
Copy link
Contributor

Choose a reason for hiding this comment

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

this is excellent!

+ " \"k3\" : true\n"
+ " \"k3-KSQL\" : true,\n"
+ " \"k2-KSQL\" : \"v2\",\n"
+ " \"k1-KSQL\" : 1\n"
Copy link
Contributor

@agavra agavra Dec 11, 2019

Choose a reason for hiding this comment

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

🤔 yet again, I missed something with my suggestion - I forgot that JSON can't represent objects as map keys! The problem with this is that if anyone is depending on our HTTP API without having access to the java JARs deserializing this would be a little though. I apologize for the back and forth, but looking at this I think we need to switch up the model a little bit.

Instead, what do you think about modeling it as a map from property to a list of (scope, value) objects? That way, the JSON API would return:

"properties": {
  "bootstrap.servers": [
    {"scope": "KSQL", "value": "foo1"}, 
    {"scope": "EMBEDDED CONNECT WORKER", "value": "foo2"}
  ]
}

let me get the opinion of some other ksqlDB committers about this (it could be that the current solution is OK)

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, we can just return a list of Property instead of a map where property contains the name, value and scope (@big-andy-coates for the idea)!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can just return a list of Property instead of a map where property contains the name, value and scope

@agavra I made required changes, could you please take a look? Thank you

@alex-dukhno alex-dukhno force-pushed the klip-impl-13-introduce-KSQL-command-to-print-connect-worker-properties-to-the-console branch from 795d922 to 256e323 Compare December 12, 2019 18:56
Copy link
Contributor

@agavra agavra left a comment

Choose a reason for hiding this comment

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

LGTM! It looks like checkstyle is failing (see inline comment). After that works there may be some other test failures (mvn clean install should catch all of them). I'll merge it when the build is green.

Thanks @alex-dukhno, this is great feature 😄

Comment on lines 78 to 82
return "Property{" +
"name='" + name + '\'' +
", scope='" + scope + '\'' +
", value='" + value + '\'' +
'}';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: our checkstyle requires + to be on the new line instead of at the end:

new "Property{"
  + "name=" + name + '\'' ...

@alex-dukhno
Copy link
Contributor Author

@agavra I fix the checkstyle issue and some tests that failed after running mvn clean install checkstyle:check integration-test locally.

Thank you for your code reviews

@agavra
Copy link
Contributor

agavra commented Dec 13, 2019

Thanks for the contribution @alex-dukhno! I've merged this PR.

@agavra agavra merged commit ebac104 into confluentinc:master Dec 13, 2019
@alex-dukhno alex-dukhno deleted the klip-impl-13-introduce-KSQL-command-to-print-connect-worker-properties-to-the-console branch December 13, 2019 18:19
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.

2 participants