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: Kafka scaler move sasl and tls config to TriggerAuthentication metadata #4024

Closed

Conversation

dttung2905
Copy link
Contributor

@dttung2905 dttung2905 commented Dec 18, 2022

Move sasl and tls config to metadata section of TriggerAuthentication

Checklist

Relates to #3611

Relates to #

@dttung2905 dttung2905 requested a review from a team as a code owner December 18, 2022 06:14
@dttung2905
Copy link
Contributor Author

Hi team,
I think this MR introduce breaking changes. Could you guide me on what should I do in this case?
Should we introduce grace period with deprecation messages or its fine to leave the MR like that with notes in the breaking changes section in the next release. The blast radius of this MR is just Kafka Scaler so the latter may be okay?

@dttung2905
Copy link
Contributor Author

Hi @JorTurFer, thanks for approving my other MR so quickly, even during weekend 🙏 Could you help to guide me on this one as well ?

@zroubalik
Copy link
Member

@dttung2905 I think that we should not move this config, but support specifying thsi option in both places. This way we maintain backwards compatibility.

There should be a check when this option is specified in both places (with different values), in this case we should fail.

WDYT @kedacore/keda-contributors ?

@dttung2905
Copy link
Contributor Author

dttung2905 commented Dec 19, 2022

@dttung2905 I think that we should not move this config, but support specifying thsi option in both places. This way we maintain backwards compatibility.

There should be a check when this option is specified in both places (with different values), in this case we should fail.

WDYT @\kedacore/keda-contributors ?

Thanks for the feedback. Yes I can make it backward compatible too. Am I right to say that we will support having tls and sasl in both places ( but not both at the same time ) in the long run ? This is just for my understanding when updating the doc in the other MR

@dttung2905
Copy link
Contributor Author

Hi @zroubalik , I have make changes to accommodate backward compatibility. Also a few checks I have implemented

  • A check to flag out when the same value of tls or sasl are set in both places
  • A check to flag out when tls and sasl are set in different places at the same time
  • A few extra sets of unit test to test out the above 2 points

Could you help to review it ?

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.

Thanks for the addition, the only nit is the changelog. Let see what other think.

CHANGELOG.md Outdated
@@ -42,7 +42,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

### Breaking Changes

- TODO
- Kafka: Move `sasl` and `tls` config to `TriggerAuthentication` metadata ([#4024](https://github.com/kedacore/keda/pull/4024))
Copy link
Member

Choose a reason for hiding this comment

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

Is this really a Brekaing Change? I am not sure, @tomkerkhove @JorTurFer wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily though. Before we decided to make it backward compatible, I classified it as breaking changes. I can move it out of this section

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so, because it's backward compatible

Copy link
Member

Choose a reason for hiding this comment

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

Based on the doc changes it looks like a breaking change as we are removing fields/parameters which we already support

Copy link
Member

Choose a reason for hiding this comment

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

I'd say that docs are outdated because based on the code, the values are read from both places

Copy link
Member

Choose a reason for hiding this comment

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

So instead of a secret, isn't the real fix that we need a plain text option in a CRD instead of moving this to metadata?

Something like:

  plainText:
  - parameter: tls
    value: true   

Because it feels better to me to keep everything part of the CRD "body" rather than some in metadata and other in the payload/body.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tomkerkhove Thanks so much for the suggestion. I'm really curious to know how does it look like with your suggestion in ScaledObject. 🤔 My guess is below ( pls cmiiw )

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: pulsar-scaledobject
  namespace: default
spec:
  scaleTargetRef:
    name: pulsar-consumer
  pollingInterval: 30
  plainText:
  - parameter: tls
    value: true 

Hi team,
What do you think about Tom's suggestion?
I'm totally fine with both approaches but I think parking it under metadata would be slightly better in terms of consistency across other scalers ( take pulsar for example )

Copy link
Member

Choose a reason for hiding this comment

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

My suggestion is not for ScaledObject, but for Trigger Authentication instead where we already have multiple auth providers and this could be another one

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the delay, I understand what @tomkerkhove proposes here, I have been thinking about the same approach, though I am not 100% sure we should provide a plaintext in TriggerAuth. Users might start using this not ideal approach for storing sensitive data. Or am I too sensitive and we should let them do this? :)

Copy link
Member

Choose a reason for hiding this comment

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

@kedacore/keda-core-contributors do you have an opinion on the plainText field in TA?

@zroubalik
Copy link
Member

zroubalik commented Jan 2, 2023

/run-e2e kafka*
Update: You can check the progress here

pkg/scalers/kafka_scaler.go Outdated Show resolved Hide resolved
pkg/scalers/kafka_scaler.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -42,7 +42,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

### Breaking Changes

- TODO
- Kafka: Move `sasl` and `tls` config to `TriggerAuthentication` metadata ([#4024](https://github.com/kedacore/keda/pull/4024))
Copy link
Member

Choose a reason for hiding this comment

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

I don't think so, because it's backward compatible

@dttung2905 dttung2905 requested a review from JorTurFer January 2, 2023 15:42
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
…ify implementation

Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
@dttung2905 dttung2905 force-pushed the fix-kafka-tls-sasl-metadata branch from a7ff0e3 to 9e03d79 Compare January 3, 2023 04:01
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
@tomkerkhove
Copy link
Member

As agreed on standup, the best location for this should be:

triggers:
- type: kafka
  metadata:
    bootstrapServers: kafka.svc:9092
    consumerGroup: my-group
    topic: test-topic
    lagThreshold: '5'
    activationLagThreshold: '3'
    offsetResetPolicy: latest
    allowIdleConsumers: false
    scaleToZeroOnInvalidOffset: false
    excludePersistentLag: false
    version: 1.0.0
+   saslAuthType: plaintext|scram_sha256|scram_sha512|oauthbearer|none
+   enableTls: true|false

@dttung2905
Copy link
Contributor Author

Closing this MR in favour of MR #4322

@dttung2905 dttung2905 closed this Mar 4, 2023
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.

4 participants