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

fix: SASL/PLAIN #255

Merged
merged 1 commit into from
Jan 7, 2025
Merged

fix: SASL/PLAIN #255

merged 1 commit into from
Jan 7, 2025

Conversation

einarmo
Copy link
Contributor

@einarmo einarmo commented Jan 6, 2025

The previous fix did not work. This is now definitely verified to be working and also makes coherent sense.

I made a fix in the OAUTHBEARER PR to fix the SASL flow to send a message even when the final state was Finished(true). My solution instead broke the flow in a different way, making it so that we send the final message twice.

This should fix it. I didn't catch it before because my kafka configuration was wrong and didn't properly require plain auth, and this particular issue doesn't affect oauthbearer. This time I've verified that it fails with InvalidSaslState without this fix, and manages to connect with it.

  • I've read the contributing section of the project CONTRIBUTING.md.
  • Signed CLA (if not already signed).

@crepererum
Copy link
Collaborator

do you think we could extend the end2end tests accordingly? It seems that we already have some tests that try to do that, but it didn't seem to reproduce your issue:

rskafka/tests/client.rs

Lines 28 to 50 in e65584d

#[tokio::test]
async fn test_sasl() {
maybe_start_logging();
if env::var("TEST_INTEGRATION").is_err() {
return;
}
if env::var("KAFKA_SASL_CONNECT").is_err() {
eprintln!("Skipping sasl test.");
return;
}
let test_cfg = maybe_skip_kafka_integration!();
// Redpanda broker doesn't support SASL/PLAIN at this moment.
if test_cfg.broker_impl != BrokerImpl::Kafka {
return;
}
ClientBuilder::new(vec![env::var("KAFKA_SASL_CONNECT").unwrap()])
.sasl_config(rskafka::client::SaslConfig::Plain(
rskafka::client::Credentials::new("admin".to_string(), "admin-secret".to_string()),
))
.build()
.await
.unwrap();
}

@einarmo
Copy link
Contributor Author

einarmo commented Jan 7, 2025

I'll look into it. My tests were also against the bitnami image, so it should be possible to reproduce the issue there.

@einarmo
Copy link
Contributor Author

einarmo commented Jan 7, 2025

Turns out you have to set KAFKA_SASL_CONNECT in integration tests.

Also the test just seems to hang before this patch, not entirely sure why. I made the test time out after 2 seconds, it passes in way less than that under normal circumstances. I ran

TEST_INTEGRATION="1" KAFKA_SASL_CONNECT="localhost:9097" KAFKA_CONNECT="localhost:9097" TEST_BROKER_IMPL="kafka" cargo test test_sasl

@einarmo
Copy link
Contributor Author

einarmo commented Jan 7, 2025

Ah, because of the infinite backoff of course. Better solution is to disable that.

@einarmo einarmo force-pushed the fix-sasl-plain branch 10 times, most recently from dc3007f to 39d5608 Compare January 7, 2025 11:27
The previous fix did not work. This is now definitely verified to be
working and also makes coherent sense.
@einarmo
Copy link
Contributor Author

einarmo commented Jan 7, 2025

This turned out to be a major hassle to get working.

The CI setup didn't configure any connection that allows SASL, so I added that which produced an error complaining about a missing jaas config. Looking into mounting that I found that doing so is essentially impossible in circleci without major changes to the build. Then I found that you were actually using very old versions of the bitnami image, maybe assuming that 3 pointed to the latest 3.* version of the image, which isn't actually the case here.

The fix was to update the kafka images and adding some more environment variables, which seems to work.

Copy link
Collaborator

@crepererum crepererum left a comment

Choose a reason for hiding this comment

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

Awesome. Thanks a lot for going the extra mile and also improve the testing. I really appreciate that!

@crepererum crepererum merged commit b905454 into influxdata:main Jan 7, 2025
11 checks passed
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