Repository navigation
Integrate the AwsVendedTokenProvider into the UCSingleCatalog - #1110
Conversation
c061b84 to
53c64d3
Compare
| long expiredTimeMillis = conf.getLong(UCHadoopConf.S3A_INIT_CRED_EXPIRED_TIME, 0L); | ||
| long expiredTimeMillis = conf.getLong( | ||
| UCHadoopConf.S3A_INIT_CRED_EXPIRED_TIME, | ||
| Long.MAX_VALUE); |
There was a problem hiding this comment.
@tdas , for the fixed credentials case, the expiration time should be infinite. That's why I changed its default value to Long.MAX_VALUE.
There was a problem hiding this comment.
I changed it because currently we TestReadWriteTest use the constant ak/sk/sessionToken to bootstrap the OSS UC server, and the uc server think it's using the fixed credentials which will never to be expired.
See:
So for the AwsVendedTokenProvider in the integrated unit test, it will request the DB UC server, and get the fixed and never-expire credentials ( without setting any expiration time ).
Thrown it here for reviewing.
There was a problem hiding this comment.
I'm not sure it's good to set it be 0 or LONG.MAX_VALUE. Seems like the document is allowed to set 0 for the expiration_time. https://docs.databricks.com/api/gcp/workspace/temporarytablecredentials/generatetemporarytablecredentials
There was a problem hiding this comment.
So the integration test in this PR is not really testing refresh at all... its only testing that the first initial cred received from actually gets injected .. thats all.
isnt it?
There was a problem hiding this comment.
Yes, that's true. For this PR, the focus is making the AwsVendedTokenProvider to go through the whole running path, I mean enabling it to the local integration test, for convincing people that after successfully configuring the renewCrednetial.enabled=true, it won't break the job for the starting process.
For the credential renewal process, it will be addressed in this e2e test: #1119
I mean we will start a long-runing job (> 30min), and continuesly run and renew the credentials whenever it's required.
There was a problem hiding this comment.
Also I can try to add the renewal local unit test, like the TableReadWriteTest. All renewal credentials will be issued from the OSS UC server. Anyway I think it's better to have separate PR to address it, since the current PR have enough complex context to address.
| } | ||
| } | ||
|
|
||
| public static class GcsPropsBuilder extends PropsBuilder<GcsPropsBuilder> { |
There was a problem hiding this comment.
GcsPropsBuilder should also have some common properties but I did not set them here. Since this PR is focused on aws s3. Finally when we design the GCS integration test, we will set those common properties here.
There was a problem hiding this comment.
then lets not even add the GcsPropsBuilder in this PR.
all the Gcs stuff can be added in a PR later.
There was a problem hiding this comment.
Fine, let's use the immutable map to set those static properties, without introducing the GcsPropsBuilder.
| private TableProps() { | ||
| } | ||
|
|
||
| public static final String FIXED_CREDENTIAL_ENABLED = "fixedCredential.enabled"; |
There was a problem hiding this comment.
Do we have any preference for the table property naming ?
| @ParameterizedTest | ||
| @ValueSource(strings = {"s3", "gs", "abfs"}) | ||
| public void testCredentialParquet(String scheme) throws ApiException, IOException { | ||
| @CsvSource({"s3, true", "s3, false", "gs, true", "abfs, true"}) |
There was a problem hiding this comment.
NOTICE: here I set the s3's fixedCredEnabled to be false, which means we will use the AwsVendedProvider to access the temporay cred from the UC server, and renew it automatically.
We don't set it for gs and abfs here. because this PR should focus on s3 e2e test. Further PR will enable the e2e test for gs and abfs.
| } | ||
| } | ||
|
|
||
| public static class GcsPropsBuilder extends PropsBuilder<GcsPropsBuilder> { |
There was a problem hiding this comment.
then lets not even add the GcsPropsBuilder in this PR.
all the Gcs stuff can be added in a PR later.
|
|
||
| import java.util.Map; | ||
|
|
||
| public class TableProps { |
There was a problem hiding this comment.
why is this table props and not an overall simple spark conf or spark sql conf?
why would anyone want to enable or disable refresh on a table-by-table basis? I expect that if someone has to set this... but they want to do it for their long-running application whatever all the tables that application is accessing.
There was a problem hiding this comment.
I think you are right. Seems like the real demand is setting at application level, not the table level. I naturally thought all credentials settings are table-level, then the flag should also be table-level. Thanks for pointing this out, then I think we will need to parse the value from the spark catalog options.
| private TableProps() { | ||
| } | ||
|
|
||
| public static final String FIXED_CREDENTIAL_ENABLED = "fixedCredential.enabled"; |
There was a problem hiding this comment.
"fixed" does not make intuitive sense to me. can we use "refresh" or "renew"?
There was a problem hiding this comment.
Done ! renamed it to renewCredential.enabled.
| uri.toString, | ||
| token, | ||
| tableId, | ||
| TableOperation.READ_WRITE, |
There was a problem hiding this comment.
why is it always READ_WRITE? shouldnt we identify what type of credential we were successful in getting and specify that type of credential to be fetched on renew (rather than trying twice everytime)?
| } else { | ||
| return s3PathTempCredProps(uri, token, path, pathOp, tempCreds); | ||
| } | ||
| case "gs": |
There was a problem hiding this comment.
we have support fs and abfss before.. why not maintain that non-renew support here as well?
There was a problem hiding this comment.
@openinx any thoughts?
i dont want this PR to break existing funcationality.
There was a problem hiding this comment.
Hi @tdas , thanks for the comment. I think the current PR also support the gs and abfss/abfs. Please see the code:
- https://github.com/unitycatalog/unitycatalog/pull/1110/files#diff-ab4ecc349cf85b6952657fa3266eb21da199d6460e0ccf4a95518e76a5ec5f15R229-R235
- https://github.com/unitycatalog/unitycatalog/pull/1110/files#diff-ab4ecc349cf85b6952657fa3266eb21da199d6460e0ccf4a95518e76a5ec5f15R204-R210
And the current PR only support the non-renew cred here, for further PR we will enable the renewal when enable them in the test.
( I'm not sure if I misunderstood the comment or not, please feel free to correct me if there is anything wrong).
There was a problem hiding this comment.
Aah .. i see. i think i got confused with not have Fixed in the function name for abfs/gs when s3 has s3FixedCredProps
| .build(); | ||
| } | ||
|
|
||
| public static Map<String, String> s3TableTempCredProps( |
There was a problem hiding this comment.
quite a bit of duplicate code between s3TableTempCredProps and s3PathTempCredProps
see if you can dedup?
the only difference is the property ... table id or path .. isnt it? maybe that can be passed as a string with a boolean flag saying its a path or a tableid?
| .build(); | ||
| } | ||
|
|
||
| public static Map<String, String> abfsProps(TemporaryCredentials tempCreds) { |
There was a problem hiding this comment.
why is there no path stuff for gs and abfs? did we not support those before?
There was a problem hiding this comment.
Enabling the credential renewal for gs and abfs, is not the target of this PR. so for gs and abfs, let's keep it as it is. The further e2e test PR will enable for gs and abfs.
There was a problem hiding this comment.
sounds good. please leave TODOs.
| long expiredTimeMillis = conf.getLong(UCHadoopConf.S3A_INIT_CRED_EXPIRED_TIME, 0L); | ||
| long expiredTimeMillis = conf.getLong( | ||
| UCHadoopConf.S3A_INIT_CRED_EXPIRED_TIME, | ||
| Long.MAX_VALUE); |
| protected static final String ACCESS_TOKEN_KEY = "fs.gs.auth.access.token.credential"; | ||
| protected static final String ACCESS_TOKEN_EXPIRATION_KEY = "fs.gs.auth.access.token.expiration"; | ||
| private Configuration conf; | ||
| public static final String ACCESS_TOKEN_KEY = "fs.gs.auth.access.token.credential"; |
There was a problem hiding this comment.
Since the CredProsUtil moved to auth package, so those two static fields need to be public.
There was a problem hiding this comment.
The following changes are fixing the checkstyle validation.
| public static final String WAREHOUSE = "warehouse"; | ||
|
|
||
| public static final String RENEW_CREDENTIAL_ENABLED = "renewCredential.enabled"; | ||
| public static final boolean DEFAULT_RENEW_CREDENTIAL_ENABLED = true; |
There was a problem hiding this comment.
please take note that if we backport this to 0.3, the default should be false.
There was a problem hiding this comment.
That's true, let me revert this back to false.
There was a problem hiding this comment.
Thanks for the comment !
| .build(); | ||
| } | ||
|
|
||
| private static Map<String, String> s3TableTempCredProps( |
There was a problem hiding this comment.
referencing this comment again about dup code
There was a problem hiding this comment.
Hi @tdas , thanks for the comment here. I think it may be better to separate those two method, since the two methods have two different arguments: tableId and tableOp vs path and pathOp.
If we make them in a unfied method, such as :
public static Map<String, String> createCredProps(
boolean renewCredEnable,
String scheme,
String uri,
String token,
String tableId,
TableOperation tableOp,
String path,
PathOperation pathOp,
TemporaryCredentials tempCreds,
boolean useTableCred,
) {
....
}It may make the caller feel some kind of confuse, because for a table temp cred, we actually don't know how to pass the path and PathOperation arguments. and vice versa. Although we can dup the implementation code, but it's hard for caller to distinguish the difference. So that's why I prefer to make them into two different methods and make them into two code paths natually.
There was a problem hiding this comment.
you could have a private method that take the s3PropsBuilder as a parameter and returns the map
private Map<String, String> buildCommonS3Props(
String uri,
String token,
TemporaryCredentials tempCreds,
S3PropsBuilder builder) {
builder.set(UCHadoopConf.S3A_CREDENTIALS_PROVIDER, AwsVendedTokenProvider.class.getName())
.uri(uri)
.token(token)
.uid(UUID.randomUUID().toString())
.set(UCHadoopConf.S3A_INIT_ACCESS_KEY, awsCred.getAccessKeyId())
.set(UCHadoopConf.S3A_INIT_SECRET_KEY, awsCred.getSecretAccessKey())
.set(UCHadoopConf.S3A_INIT_SESSION_TOKEN, awsCred.getSessionToken());
// For the static credential case, nullable expiration time is possible.
if (tempCreds.getExpirationTime() != null) {
builder.set(UCHadoopConf.S3A_INIT_CRED_EXPIRED_TIME,
String.valueOf(tempCreds.getExpirationTime()));
}
return builder.build();
}
and then this method can simply be
S3PropsBuilder builder = new S3PropsBuilder()
builder.credentialType(UCHadoopConf.UC_CREDENTIALS_TYPE_TABLE_VALUE)
.tableId(tableId)
.tableOperation(tableOp);
return buildCommonS3Props(...builder...);
isnt this code deduplication without introducing confusing public methods?
There was a problem hiding this comment.
Thanks for the great point which I did not think of before. I'd love to apply it in the PR.
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
c9bcb3e to
172a69f
Compare
|
The broken test is unrelated to this PR: Downloaded https://repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.3/checker-compat-qual-2.5.3.jar
Downloaded https://repo1.maven.org/maven2/org/jline/jline/3.27.1/jline-3.27.1-jdk8.jar.sha512
Downloaded https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.16/scala-compiler-2.13.16.jar
Downloaded https://repo1.maven.org/maven2/org/glassfish/hk2/hk2-api/3.0.6/hk2-api-3.0.6.jar
Downloaded https://repo1.maven.org/maven2/org/jline/jline/3.27.1/jline-3.27.1-jdk8.jar
Downloaded https://repo1.maven.org/maven2/org/rocksdb/rocksdbjni/9.8.4/rocksdbjni-9.8.4.jar
[info] compiling 73 Java sources to /home/runner/work/unitycatalog/unitycatalog/server/target/models/target/classes ...
[info] compiling 96 Java sources to /home/runner/work/unitycatalog/unitycatalog/target/clients/java/target/classes ...
Generated classpath file '/home/runner/work/unitycatalog/unitycatalog/target/classpath'
Generated classpath file '/home/runner/work/unitycatalog/unitycatalog/target/control/java/target/classpath'
Generated classpath file '/home/runner/work/unitycatalog/unitycatalog/server/target/controlmodels/target/classpath'
Generated classpath file '/home/runner/work/unitycatalog/unitycatalog/clients/python/target/classpath'
[info] done compiling
Generated classpath file '/home/runner/work/unitycatalog/unitycatalog/server/target/models/target/classpath'
[info] compiling 107 Java sources to /home/runner/work/unitycatalog/unitycatalog/server/target/classes ...
[info] done compiling
Generated classpath file '/home/runner/work/unitycatalog/unitycatalog/target/clients/java/target/classpath'
[info] compiling 21 Java sources to /home/runner/work/unitycatalog/unitycatalog/examples/cli/target/classes ...
[info] done compiling
Generated classpath file '/home/runner/work/unitycatalog/unitycatalog/examples/cli/target/classpath'
[info] done compiling
Generated classpath file '/home/runner/work/unitycatalog/unitycatalog/server/target/classpath'
[error] Missing org.scala-lang:scala2-sbt-bridge:2.13.16:compile
[error] (spark / scalaCompilerBridgeBinaryJar) Missing org.scala-lang:scala2-sbt-bridge:2.13.16:compile
>> Stopped the server
Error: Process completed with exit code 1.Let's try it again. |
Signed-off-by: Zheng Hu <[email protected]>
The CI reports the artifact downloading error, let's retry it again. |
|
4 broken tests, let me take a look: |
Signed-off-by: Zheng Hu <[email protected]>
0985c73 to
1760b1b
Compare
| private OptionsUtil() { | ||
| } | ||
|
|
||
| public static final String URI = "uri"; |
There was a problem hiding this comment.
good to make a note that that is is not the full configuration key
|
|
||
| import java.util.Map; | ||
|
|
||
| public class OptionsUtil { |
There was a problem hiding this comment.
These are configurations.. not options. Specifically configurations of the UCSingleCatalog.. right?
So options is very generic name.
Better to name this SparkConfs or more specifically .. UCSingleCatalogConfs.
There was a problem hiding this comment.
few minor comments on internal class names. please address them in follow up PRs.
thank you for the integration test. i hope to see the improvements with actual credential renewal being tested in the integration test with the appropriate mocking framework.
…atalog#1110) **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [x] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Related issue: unitycatalog#1092 Let's add the integration test for `AwsVendedTokenProvider` in this PR. --------- Signed-off-by: Zheng Hu <[email protected]> Signed-off-by: TimothyW553 <[email protected]>
…nitycatalog#1110) **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [x] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Related issue: unitycatalog#1092 Let's add the integration test for `AwsVendedTokenProvider` in this PR. --------- Signed-off-by: Zheng Hu <[email protected]>
PR Checklist
docsis updatedDescription of changes
Related issue: #1092
Let's add the integration test for
AwsVendedTokenProviderin this PR.