-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
HADOOP-17053. ABFS: Fix Account-specific OAuth config setting parsing #2034
Conversation
Accounts are in East US2 region. HNS Account: |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
* @return Highest-precedence Class object that was found | ||
*/ | ||
public <U> Class<? extends U> getClass(String name, Class<? extends U> defaultValue, Class<U> xface) { | ||
public <U> Class<? extends U> getTokenProviderClass(AuthType authType, |
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.
nit: I could see it from the javadocs, still naming it something like authTypeForAccount could improve readability
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.
This method fetches TokenProviderClass instance based on the input AuthType. It is in sync with the naming followed by other methods that resolve account-specific config and in it's absence default to account-agnostic value. Will retain the naming.
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 meant for the parameter currently named authType
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.
Inputs AuthType, name of the relevant TokenProvider config key, xface (interface) are derived by the caller of getTokenProviderClass based on account-specific config settings. As it applies to all the inputs equally and is clear from the calling method's perspective, will retain the naming.
import org.apache.hadoop.conf.Configuration; | ||
|
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.
Nit: This new line can be removed
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.
Fixed.
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.
LGTM
🎊 +1 overall
This message was automatically generated. |
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.
Looks good, +1
When AuthType and Auth token provider configs are set for both generic (account-agnostic) and account-specific config, as below:
// account agnostic
fs.azure.account.auth.type=CUSTOM
fs.azure.account.oauth.provider.type=ClassExtendingCustomTokenProviderAdapter
// account specific
fs.azure.account.auth.type.account_name=OAuth
fs.azure.account.oauth.provider.type.account_name=ClassExtendingAccessTokenProvider
Effective token provider for 'account_name' is expected to be ClassExtendingAccessTokenProvider.
But currently, when the token provider class is being read from the config, account-agnostic config setting is read first in the assumption that it can serve as default if account-specific config setting is absent.
This logic leads to failure such as in above case where AuthType for account-specific and AuthType for account-agnostic are different. This is because the Interface implementing the token provider is different for various Auth Types (For Custom AuthType it is CustomTokenProviderAdapter and for OAuth it is AccessTokenProvider). This leads to a Runtime exception when trying to create the oAuth access token provider.
In this PR, getTokenProvider() is fixed to check for account-specific token provider configuration first. In its absence, account-agnostic token provider configuration is read only if account-specific and account-agnostic AuthType setting is same (otherwise expected token provider interface is different). The same logic applies while determining SAS Token provider too, hence that has been updated as well.
Testing is done with combinations of Custom and OAuth settings in account-specific and account-agnostic configs and determining which is in effect. Tested getSASTokenProvider which uses the same logic to find the effective token provider with SAS set for both account-specific and account-agnostic configs.