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

Seldon add ssl #3813

Merged
merged 20 commits into from
Jan 17, 2022
Merged

Seldon add ssl #3813

merged 20 commits into from
Jan 17, 2022

Conversation

stephen37
Copy link
Contributor

@stephen37 stephen37 commented Dec 21, 2021

What this PR does / why we need it:
Add capabilities to use SSL when using Kafka when logging payloads or using Kafka server type.

Which issue(s) this PR fixes:

Special notes for your reviewer:
None

Does this PR introduce a user-facing change?:

Added capabilities to use SSL when using Kafka when logging payloads or using Kafka server type. The options that are being exposed are `ssl.ca.location`, `ssl.key.location`, `ssl.certificate.location` and `ssl.key.password`. 
Added configuration tests for the different options exposed.

executor/logger/worker.go Outdated Show resolved Hide resolved
executor/logger/worker.go Outdated Show resolved Hide resolved
@agrski
Copy link
Contributor

agrski commented Dec 22, 2021

Alongside the extra functionality added in this PR, it'd be good to have documentation explaining at least what SSL options are available (e.g. that key/cert files can be provided but not directly the equivalent strings)

To avoid having to write the same piece of code twice, I refactored the
code.
I cannot get the test to do what I want though, if I don't set a
`broker` then it just hangs and if I set a broker then it throws an
error with
```
%7|1640872656.856|BROKERFAIL|rdkafka#producer-1| [thrd:ssl://broker:9092/bootstrap]: ssl://broker:9092/bootstrap: failed: err: Local: Host resolution failure: (errno: Bad address)
%7|1640872656.856|STATE|rdkafka#producer-1| [thrd:ssl://broker:9092/bootstrap]: ssl://broker:9092/bootstrap: Broker changed state CONNECT -> DOWN
%7|1640872656.856|BROADCAST|rdkafka#producer-1| [thrd:ssl://broker:9092/bootstrap]: Broadcasting state change
%7|1640872656.856|BUFQ|rdkafka#producer-1| [thrd:ssl://broker:9092/bootstrap]: ssl://broker:9092/bootstrap: Purging bufq with 0 buffers
%7|1640872656.856|BUFQ|rdkafka#producer-1| [thrd:ssl://broker:9092/bootstrap]: ssl://broker:9092/bootstrap: Purging bufq with 0 buffers
%7|1640872656.856|BUFQ|rdkafka#producer-1| [thrd:ssl://broker:9092/bootstrap]: ssl://broker:9092/bootstrap: Updating 0 buffers on connection reset
```
Comment on lines 202 to 208
// myOAuthConfig := "scope=myscope principal=gotest"
// p, err := kafka.NewProducer(&kafka.ConfigMap{
// "security.protocol": "SASL_PLAINTEXT",
// "sasl.mechanisms": "OAUTHBEARER",
// "sasl.oauthbearer.config": myOAuthConfig,
// })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That part is only here if you wanna run a debug test and check what the producer is creating.

executor/api/util/utils.go Outdated Show resolved Hide resolved
executor/api/kafka/server.go Outdated Show resolved Hide resolved
executor/api/kafka/server.go Outdated Show resolved Hide resolved
executor/api/kafka/server.go Outdated Show resolved Hide resolved
@agrski
Copy link
Contributor

agrski commented Jan 6, 2022

Based on this section in the confluent-kafka-go repo, it looks like there is a lack of support for test mocks and the module expects a real cluster.

I've also been completely unable to find anything useful related to mocks or fakes by grepping through that repo (via the downloaded Go module, v.1.4.2, which matches the repo contents).

I suppose that leaves two options:

  1. Create a real broker, which means settings up a full cluster with Zookeeper, etc.
  2. Have no tests (or only very, very simple ones)

The first option feels like overkill for what amounts to parameter-passing unit tests We may want to look at integration tests for the variation combinations of options for all this in the future.

@agrski
Copy link
Contributor

agrski commented Jan 6, 2022

I've created #3830 to track integration tests for Kafka

executor/api/util/utils.go Outdated Show resolved Hide resolved
@stephen37 stephen37 marked this pull request as ready for review January 14, 2022 12:43
executor/logger/worker.go Outdated Show resolved Hide resolved
Copy link
Contributor

@agrski agrski left a comment

Choose a reason for hiding this comment

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

Nice work on this! Although I've not tested against a live Kafka setup, LGTM and should have no impact if SSL is not in use

Copy link
Contributor

@agrski agrski left a comment

Choose a reason for hiding this comment

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

LGTM

@seldondev
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: agrski

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants