-
Notifications
You must be signed in to change notification settings - Fork 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-19471. ABFS: Support Fixed SAS Token at Container Level #7461
base: trunk
Are you sure you want to change the base?
Conversation
💔 -1 overall
This message was automatically generated. |
c5b14bb
to
4a182ac
Compare
🎊 +1 overall
This message was automatically generated. |
passchars = rawConfig.getPassword(accountConf(key)); | ||
if(passchars == null){ | ||
passchars = rawConfig.getPassword(key); | ||
} |
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.
can be simplified as :- char[] passchars = rawConfig.getPassword(containerConf(key)) != null ?
rawConfig.getPassword(containerConf(key)) :
rawConfig.getPassword(accountConf(key)) != null ?
rawConfig.getPassword(accountConf(key)) :
rawConfig.getPassword(key);
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.
Taken
@@ -493,7 +497,7 @@ public AbfsConfiguration(final Configuration rawConfig, | |||
*/ | |||
public AbfsConfiguration(final Configuration rawConfig, String accountName) |
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.
Ideally we should add a separate constructor with this new param
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.
Taken
* Helper method to get the Fixed SAS token value | ||
*/ | ||
private String getFixedSASToken(AbfsConfiguration config) throws Exception { | ||
return config.getSASTokenProvider().getSASToken(this.getAccountName(), this.getFileSystemName(), getMethodName(), "read"); |
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: use constants for string
🎊 +1 overall
This message was automatically generated. |
Test Results============================================================
|
b2cb26d
to
6915d0e
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@@ -150,7 +150,9 @@ public void testBothProviderFixedTokenConfigured() throws Exception { | |||
* Helper method to get the Fixed SAS token value | |||
*/ | |||
private String getFixedSASToken(AbfsConfiguration config) throws Exception { | |||
return config.getSASTokenProvider().getSASToken(this.getAccountName(), this.getFileSystemName(), getMethodName(), "read"); | |||
String readPermission = "read"; |
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 should be a static string used as a constant.
testAbfsConfig.set(FS_AZURE_SAS_FIXED_TOKEN, accountSAS); | ||
|
||
// Assert that Container Specific Fixed SAS is used | ||
Assertions.assertThat(getFixedSASToken(testAbfsConfig)).contains("sr=c"); |
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.
Please add description for this.
|
||
// Assert that Account Specific Fixed SAS is used if container SAS isn't set | ||
testAbfsConfig.unset(containerProperty(FS_AZURE_SAS_FIXED_TOKEN, this.getFileSystemName(), this.getAccountName())); | ||
Assertions.assertThat(getFixedSASToken(testAbfsConfig)).contains("ss=bf"); |
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.
Same as above, please add description in all the assert.
//Assert that Account-Agnostic fixed SAS is used if no other fixed SAS configs are set. | ||
// The token is the same as the Account Specific Fixed SAS. | ||
testAbfsConfig.unset(accountProperty(FS_AZURE_SAS_FIXED_TOKEN, this.getAccountName())); | ||
Assertions.assertThat(getFixedSASToken(testAbfsConfig)).contains("ss=bf"); |
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.
Same as above.
* Helper method to get the Fixed SAS token value | ||
*/ | ||
private String getFixedSASToken(AbfsConfiguration config) throws Exception { | ||
return config.getSASTokenProvider().getSASToken(this.getAccountName(), this.getFileSystemName(), getMethodName(), |
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.
Please review the format. This line has too many characters.
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.
Corrected
@@ -322,6 +322,10 @@ public static String accountProperty(String property, String account) { | |||
return property + "." + account; | |||
} | |||
|
|||
public static String containerProperty(String property, String fsName, String account) { | |||
return property + "." + fsName + "." + account; |
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.
We can use DOT constant here (AbfsHttpConstants)
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.
Taken
* @return Container-specific configuration key | ||
*/ | ||
public String containerConf(String key) { | ||
return key + "." + fsName + "." + accountName; |
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.
We can use DOT constant here (AbfsHttpConstants)
0969033
to
f4c6458
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +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.
Some changes in test code needed
* @throws IOException | ||
*/ | ||
@Test | ||
public void testFixedTokenPreference() throws Exception { |
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: `testFixedSASTokenProviderPreference'
testAbfsConfig.set(FS_AZURE_SAS_FIXED_TOKEN, accountSAS); | ||
|
||
// Assert that Container Specific Fixed SAS is used | ||
Assertions.assertThat(getFixedSASToken(testAbfsConfig)) |
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 seems good but you can also assert on the whole SAS Token string.
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.
Taken
testAbfsConfig.set( | ||
containerProperty(FS_AZURE_SAS_FIXED_TOKEN, this.getFileSystemName(), | ||
this.getAccountName()), containerSAS); | ||
testAbfsConfig.set( |
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.
We are setting same SAS Token as both account specific and account agnostic. We should separate them out.
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.
Makes sense, taken.
accountProperty(FS_AZURE_SAS_FIXED_TOKEN, this.getAccountName())); | ||
Assertions.assertThat(getFixedSASToken(testAbfsConfig)) | ||
.describedAs("Account-agnostic fixed SAS should've been used.") | ||
.contains("ss=bf"); |
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 assert should be different from other else it won't be able to catch regressions
22851b7
to
a800cda
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Description of PR
The ABFS driver currently lacks support for multiple SAS tokens for the same storage account across different containers.
Introducing this support through this PR.
To use fixed SAS token at container level the configuration to be used is:
fs.azure.sas.fixed.token.<container-name>.<storage-account-name>
How was this patch tested?
Adding the test results in the comments below.