-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Set effective user of (web)hdfs hooks using connection config, optionally overridden by constructor #942
Conversation
I like the idea, but I what about using the username from the Connection object instead if/when it is defined? You could just set the proxy user in the HDFSHook constructor. |
well, that makes sense. I missed that. |
32f27f1
to
afb9ed8
Compare
PR updated. Now if login is set into the connection, it is used as proxy user. I preferred to have also a way to override it in the constructor, since it can be useful in certain situations, where you have to deal with different proxy users and defining an hdfs connection for each one can be "too static". |
bd4b251
to
c132866
Compare
… WebHDFSHook, optionally allow to override it in the constructor. Add simple init test for WebHDFS.
bc5bae0
to
9a3a755
Compare
PR updated to include webhdfs proxy user support. |
client.content('/') | ||
proxy_user = self.proxy_user or nn.login | ||
client = InsecureClient(connection_str, user=proxy_user) | ||
client.status('/') |
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.
I'm not familiar with the lib, what is this change about?
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.
As I understand, the content method is called to check if the namenode is valid, but it fails also on current airflow, if the task is run as any user != hdfs, while the status method will not, so I think that calling status is better for checking the namenode validity.
The other change is for adding the "doAs" also to the hdfs client.
Awesome. Thanks for this contribution. |
Set effective user of (web)hdfs hooks using connection config, optionally overridden by constructor
Can confirm. Content was a way to check the validity of namenode. Thanks for this! |
Sometimes is needed to do hdfs operations on behalf of other users (like creating dirs or setting permissions), so this PR adds a simple method to do that (optionally, without breaking compatibility).