Skip to content

Apply GCP Application Default authentication when using a Managed Service for Apache Kafka cluster.#2925

Merged
fozzie15 merged 2 commits intoGoogleCloudPlatform:mainfrom
fozzie15:gmk_with_streaming_generator
Oct 28, 2025
Merged

Apply GCP Application Default authentication when using a Managed Service for Apache Kafka cluster.#2925
fozzie15 merged 2 commits intoGoogleCloudPlatform:mainfrom
fozzie15:gmk_with_streaming_generator

Conversation

@fozzie15
Copy link
Contributor

This change allows the streaming data generator to be used in conjunction with Google's Managed Service for Apache Kafka.

Due to the lack of ability to create UTs/ITs which create and utilize Managed Service resources and the existing flakiness of the kafka IT, this was tested manually. 4 tests were conducted:

  1. JSON using local Kafka cluster
  2. JSON using Managed Service cluster
  3. Avro using local Kafka cluster
  4. Avro using Managed Service cluster

These were conducted by modifying the existing Kafka Integration test to utilize these resources as necessary. These cases all pass, and I observed data moving through both kafka clusters.

@gemini-code-assist
Copy link

Summary of Changes

Hello @fozzie15, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for Google's Managed Service for Apache Kafka within the streaming data generator. The core change involves dynamically applying GCP Application Default Credentials when the Kafka bootstrap server URL matches a pattern indicative of a Managed Kafka instance. This ensures proper authentication and enables the data generator to seamlessly interact with these managed services.

Highlights

  • GCP Managed Kafka Support: The streaming data generator now supports Google's Managed Service for Apache Kafka by applying GCP Application Default Credentials.
  • Conditional Authentication: A regular expression is used to detect Managed Kafka bootstrap servers, and GCP authentication is conditionally enabled only for these services.
  • Manual Testing: Extensive manual testing was performed across JSON and Avro data formats with both local and Managed Service Kafka clusters, confirming successful data flow.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.03%. Comparing base (28c40d0) to head (d654280).
⚠️ Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
...transforms/StreamingDataGeneratorWriteToKafka.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2925      +/-   ##
============================================
- Coverage     50.06%   50.03%   -0.03%     
- Complexity     4967     4971       +4     
============================================
  Files           967      967              
  Lines         59292    59331      +39     
  Branches       6440     6449       +9     
============================================
+ Hits          29687    29689       +2     
- Misses        27502    27537      +35     
- Partials       2103     2105       +2     
Components Coverage Δ
spanner-templates 70.45% <ø> (-0.06%) ⬇️
spanner-import-export 68.96% <ø> (-0.12%) ⬇️
spanner-live-forward-migration 79.69% <ø> (-0.05%) ⬇️
spanner-live-reverse-replication 77.42% <ø> (-0.01%) ⬇️
spanner-bulk-migration 88.21% <ø> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
...transforms/StreamingDataGeneratorWriteToKafka.java 0.00% <0.00%> (ø)

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fozzie15 fozzie15 force-pushed the gmk_with_streaming_generator branch from 8bbf84d to f6abe98 Compare October 24, 2025 20:29
@fozzie15 fozzie15 added the improvement Making existing code better label Oct 24, 2025
@fozzie15 fozzie15 merged commit 05855e4 into GoogleCloudPlatform:main Oct 28, 2025
20 of 21 checks passed
aasthabharill pushed a commit that referenced this pull request Dec 10, 2025
…vice for Apache Kafka cluster. (#2925)

* Add logic to apply GCP Application Default authentication when using a Managed Service for Apache Kafka cluster

* Tighten the regex for better matching on google clusters.
MnkyGns pushed a commit to MnkyGns/DataflowTemplates that referenced this pull request Feb 12, 2026
…vice for Apache Kafka cluster. (GoogleCloudPlatform#2925)

* Add logic to apply GCP Application Default authentication when using a Managed Service for Apache Kafka cluster

* Tighten the regex for better matching on google clusters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Making existing code better size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants