-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add Kerberos authentication support to HadoopFileSystem #20719 #37290
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @haseebmalik18, 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 enhances the Python HadoopFileSystem by integrating Kerberos authentication, providing a secure way to interact with HDFS. It introduces a new configuration option to switch between insecure and Kerberos-based client types, ensuring that users can leverage robust security protocols when accessing their Hadoop Distributed File System resources. This change significantly improves the security posture for Beam pipelines interacting with HDFS. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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
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 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
|
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds Kerberos authentication support to the HadoopFileSystem, which is a great feature. The implementation is clean and follows existing patterns in the codebase. I've added a few suggestions to improve robustness and error handling. The new unit tests are comprehensive and cover the new functionality well. I also noticed a minor formatting issue in the CHANGES.md file.
| ## Highlights | ||
|
|
||
| - For versions 2.19.0 and older release notes are available on [Apache Beam Blog](https://beam.apache.org/blog/). | ||
| - - For versions 2.19.0 and older release notes are available on [Apache Beam Blog](https://beam.apache.org/blog/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like there's an extra hyphen - here, which will render as a nested list item. Was this intentional? If not, it should probably be removed to maintain consistent formatting.
| - - For versions 2.19.0 and older release notes are available on [Apache Beam Blog](https://beam.apache.org/blog/). | |
| - For versions 2.19.0 and older release notes are available on [Apache Beam Blog](https://beam.apache.org/blog/). |
|
|
||
| # Create HDFS client based on authentication type | ||
| url = 'http://%s:%s' % (hdfs_host, str(hdfs_port)) | ||
| if hdfs_client == 'KERBEROS': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the client selection more robust, it would be good to perform a case-insensitive comparison. While argparse enforces the choices case-sensitively, options can also be passed as a dictionary where case might not be consistent. Using .upper() would handle KERBEROS, kerberos, etc.
| if hdfs_client == 'KERBEROS': | |
| if hdfs_client.upper() == 'KERBEROS': |
| except Exception as e: | ||
| raise RuntimeError( | ||
| 'Failed to create KerberosClient. Ensure you have valid Kerberos ' | ||
| 'credentials (run kinit) or have configured a keytab. ' | ||
| 'Error: %s' % str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When re-raising the exception, it's better to use raise from to preserve the original exception's traceback. This is very helpful for debugging. The current implementation hides the original exception type and stack trace.
Also, consider using an f-string for formatting the error message for better readability, as the project seems to be on a modern Python version.
| except Exception as e: | |
| raise RuntimeError( | |
| 'Failed to create KerberosClient. Ensure you have valid Kerberos ' | |
| 'credentials (run kinit) or have configured a keytab. ' | |
| 'Error: %s' % str(e)) | |
| except Exception as e: | |
| raise RuntimeError( | |
| 'Failed to create KerberosClient. Ensure you have valid Kerberos ' | |
| 'credentials (run kinit) or have configured a keytab. ' | |
| f'Error: {e}') from e |
Closes #20719
Adds Kerberos authentication support to Python HadoopFileSystem via new
--hdfs_clientflag.Changes:
--hdfs_clientoption (default:INSECURE, new:KERBEROS)hdfs.ext.kerberos.KerberosClientfor Kerberos moderequests-kerberosdependency to hadoop extraUsage: