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

accept 'disable' as a valid tls value for kafka scaler #2611

Merged
merged 2 commits into from
Feb 14, 2022

Conversation

gunniwho
Copy link
Contributor

@gunniwho gunniwho commented Feb 8, 2022

Signed-off-by: Gunnar Palsson gunniwho@gmail.com

Provide a description of what has been changed

Accepts disable as a valid value for the tls auth parameter of the kafka scaler.

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO - learn more)
  • Tests have been added
  • A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Changelog has been updated and is aligned with our changelog requirements

Fixes #2608

Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

@gunniwho could you please add some tests for this parameter?

@gunniwho
Copy link
Contributor Author

gunniwho commented Feb 9, 2022

@zroubalik I could try but I don't have any experience writing go code. Should the test be added to the kafka scaler e2e tests?

@zroubalik
Copy link
Member

@gunniwho thanks, unit tests are enough for this feature imho, they are located here: https://github.com/kedacore/keda/blob/main/pkg/scalers/kafka_scaler_test.go

it is just about adding validation for this field. Thanks a lot!

@JorTurFer
Copy link
Member

JorTurFer commented Feb 9, 2022

I'm missing something, is not adding disable like having the default value?
I mean, in this case tls refers to the authentication method and not the usage of SSL/TLS protocol itself. Probably I'm wrong because I have never used Kafka before, but reading the docs that's what I understand

@nilayasiktoprak
Copy link
Contributor

I'm missing something, is not adding disable like having the default value? I mean, in this case tls refers to the authentication method and not the usage of SSL/TLS protocol itself. Probably I'm wrong because I have never used Kafka before, but reading the docs that's what I understand

I agree with @JorTurFer. In the docs( https://keda.sh/docs/2.6/scalers/apache-kafka/#authentication-parameters ), it is indicated that if you don't pass the tls value, it means it's disabled which is the default. So that's the way to disable tls if you don't want to use it.
However, I think it's a better practice to pass the tls anyway whether it's enabled or disabled in the yaml so that it will be more clear.

@gunniwho
Copy link
Contributor Author

gunniwho commented Feb 9, 2022

I'm missing something, is not adding disable like having the default value? I mean, in this case tls refers to the authentication method and not the usage of SSL/TLS protocol itself. Probably I'm wrong because I have never used Kafka before, but reading the docs that's what I understand

@JorTurFer No, you're absolutely right. However, my motivation for this is that when creating the TokenAuthentication resource it was much harder for me (because reasons...) to not include the tls parameter than to include it as 'disable'. I just found it really weird that I couldn't do it.

@JorTurFer
Copy link
Member

The point is that in this case it could be confusing because TLS sounds like transport encryption and not like client authentication method. Maybe we should rename them into more explicit keys.
Also, the documentation is wrong because true and false are invalid values:

image

IMHO we should rename the authentication method and honor TLS key if we want to allow secure/insecure traffic (if Kafka supports it, IDK) or keep it there for backward compatibility during some versions if not. But related with this, I don't see any necessity of adding extra code to explicitly set disable. Removing the else block sounds more correct to me (and it'll allow disable too).

WDYT @kedacore/keda-core-contributors ?

BTW: Thanks for exposing the problem and for the contribution ❤️ ❤️ ❤️

@gunniwho
Copy link
Contributor Author

gunniwho commented Feb 9, 2022

@JorTurFer I agree that it would be better to just remove the else block, effectively saying that passing anything other than 'enable' for this value just means that it's not enabled. It was annoying that it was throwing errors for seemingly no reason.

Regarding the docs, I also did PR to fix them (for 2.7.0 - was asked to also fix for previous versions).

Regarding the TLS naming, I don't have an opinion at all...

@tomkerkhove
Copy link
Member

I think this change makes sense so that we only log errors for invalid configuration.

What is your question @JorTurFer? I'm not sure if I get the proposal.

@JorTurFer
Copy link
Member

JorTurFer commented Feb 9, 2022

The point is that tls usually means Transport Layer Security but in Kafka scaler (AFAIK) means SSL authentication. You can use user/password (sasl) or certificate (tls). It's not related with the common meaning of tls and it could be confusing.
My proposal is renaming tls into certificate and decide if we want to support (if Kafka supports it) Transport Layer Security do it like we are doing in other scalers with something like unsafeSsl or similar.

Related with this PR in specific, my proposal is removing the else block directly

@gunniwho
Copy link
Contributor Author

gunniwho commented Feb 9, 2022

The tls option is not synonymous with certificate authentication for this scaler. It can be used to authenticate using certs (I think) but it is also the way to specify that you want to use the SASL authentication over a secured connection. If you specify sasl and not tls the credentials (or hashes in the case of scram) are sent over an insecure connection.

@JorTurFer
Copy link
Member

The tls option is not synonymous with certificate authentication for this scaler. It can be used to authenticate using certs (I think) but it is also the way to specify that you want to use the SASL authentication over a secured connection. If you specify sasl and not tls the credentials (or hashes in the case of scram) are sent over an insecure connection.

That's why I propose to extract the real tls part from the certificate authentication. Not in this PR obviously, in fact, I'll create an issue and we can discuss it there. Sorry for the noise

@gunniwho gunniwho force-pushed the accept-disable-as-valid-tls-value branch from 0f983d9 to 46f1621 Compare February 9, 2022 21:37
@gunniwho
Copy link
Contributor Author

gunniwho commented Feb 9, 2022

@gunniwho thanks, unit tests are enough for this feature imho, they are located here: https://github.com/kedacore/keda/blob/main/pkg/scalers/kafka_scaler_test.go

it is just about adding validation for this field. Thanks a lot!

done

@zroubalik
Copy link
Member

The tls option is not synonymous with certificate authentication for this scaler. It can be used to authenticate using certs (I think) but it is also the way to specify that you want to use the SASL authentication over a secured connection. If you specify sasl and not tls the credentials (or hashes in the case of scram) are sent over an insecure connection.

That's why I propose to extract the real tls part from the certificate authentication. Not in this PR obviously, in fact, I'll create an issue and we can discuss it there. Sorry for the noise

If I am not mistaken tls and sasl is being used for this specific purposes in Kafka world. I think the scaler should align with that.

Copy link
Member

@JorTurFer JorTurFer left a comment

Choose a reason for hiding this comment

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

LGTM!

@JorTurFer
Copy link
Member

hey @gunniwho ,
Your last 2 commits are not signed. Could you sign them?
https://github.com/kedacore/keda/blob/main/CONTRIBUTING.md#i-didnt-sign-my-commit-now-what

@gunniwho gunniwho force-pushed the accept-disable-as-valid-tls-value branch from 413bbb8 to 3f3914a Compare February 14, 2022 20:53
Signed-off-by: Gunnar Palsson <gunniwho@gmail.com>
Signed-off-by: Gunnar Palsson <gunniwho@gmail.com>
@gunniwho gunniwho force-pushed the accept-disable-as-valid-tls-value branch from 3f3914a to a876497 Compare February 14, 2022 21:09
Copy link
Member

@JorTurFer JorTurFer left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution ❤️

@JorTurFer JorTurFer merged commit 5898347 into kedacore:main Feb 14, 2022
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.

No way to specify TLS disabled for Kafka scaler
5 participants