Skip to content

Integrate the AwsVendedTokenProvider into the UCSingleCatalog - #1110

Merged
tdas merged 16 commits into
unitycatalog:mainfrom
openinx:1092-s3-it-test
Oct 21, 2025
Merged

tdas merged 16 commits into
unitycatalog:mainfrom
openinx:1092-s3-it-test

Conversation

@openinx

@openinx openinx commented Oct 10, 2025

Copy link
Copy Markdown
Collaborator

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Related issue: #1092

Let's add the integration test for AwsVendedTokenProvider in this PR.

@openinx
openinx marked this pull request as draft October 10, 2025 20:09
@openinx
openinx force-pushed the 1092-s3-it-test branch 4 times, most recently from c061b84 to 53c64d3 Compare October 14, 2025 23:43
@openinx
openinx marked this pull request as ready for review October 15, 2025 05:20
long expiredTimeMillis = conf.getLong(UCHadoopConf.S3A_INIT_CRED_EXPIRED_TIME, 0L);
long expiredTimeMillis = conf.getLong(
UCHadoopConf.S3A_INIT_CRED_EXPIRED_TIME,
Long.MAX_VALUE);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdas , for the fixed credentials case, the expiration time should be infinite. That's why I changed its default value to Long.MAX_VALUE.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

if (s3StorageConfig.getSessionToken() != null && !s3StorageConfig.getSessionToken().isEmpty()) {
// if a session token was supplied, then we will just return static session credentials
return Credentials.builder()
.accessKeyId(s3StorageConfig.getAccessKey())
.secretAccessKey(s3StorageConfig.getSecretKey())
.sessionToken(s3StorageConfig.getSessionToken())
.build();
}

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me think about it.

@tdas tdas Oct 20, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then lets not even add the GcsPropsBuilder in this PR.
all the Gcs stuff can be added in a PR later.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"})

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tdas tdas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bunch of comments.

}
}

public static class GcsPropsBuilder extends PropsBuilder<GcsPropsBuilder> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"fixed" does not make intuitive sense to me. can we use "refresh" or "renew"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ! renamed it to renewCredential.enabled.

uri.toString,
token,
tableId,
TableOperation.READ_WRITE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, done !

} else {
return s3PathTempCredProps(uri, token, path, pathOp, tempCreds);
}
case "gs":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have support fs and abfss before.. why not maintain that non-renew support here as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@openinx any thoughts?
i dont want this PR to break existing funcationality.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tdas , thanks for the comment. I think the current PR also support the gs and abfss/abfs. Please see the code:

  1. https://github.com/unitycatalog/unitycatalog/pull/1110/files#diff-ab4ecc349cf85b6952657fa3266eb21da199d6460e0ccf4a95518e76a5ec5f15R229-R235
  2. 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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there no path stuff for gs and abfs? did we not support those before?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me think about it.

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";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the CredProsUtil moved to auth package, so those two static fields need to be public.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take note that if we backport this to 0.3, the default should be false.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, let me revert this back to false.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment !

.build();
}

private static Map<String, String> s3TableTempCredProps(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

referencing this comment again about dup code

#1110 (comment)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@openinx

openinx commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator Author

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.

@openinx openinx closed this Oct 20, 2025
@openinx openinx reopened this Oct 20, 2025
@openinx

openinx commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator Author
[error] Caused by: lmcoursier.internal.shaded.coursier.cache.ArtifactError$DownloadError: download error: Caught java.nio.channels.OverlappingFileLockException while downloading https://repo1.maven.org/maven2/org/scala-lang/scala2-sbt-bridge/2.13.16/scala2-sbt-bridge-2.13.16.jar
[error] 	at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$.helper$2(Downloader.scala:793)

The CI reports the artifact downloading error, let's retry it again.

@openinx openinx closed this Oct 20, 2025
@openinx openinx reopened this Oct 20, 2025
@openinx openinx changed the title Add AwsVendedTokenProvider integration test. Integrate the AwsVendedTokenProvider into the UCSingleCatalog Oct 20, 2025
@openinx openinx closed this Oct 20, 2025
@openinx openinx reopened this Oct 20, 2025
@openinx

openinx commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator Author

4 broken tests, let me take a look:

2025-10-20T21:55:45.2701915Z [error] Test io.unitycatalog.spark.TableReadWriteTest.testCredentialCreateDeltaTable failed: java.lang.IllegalArgumentException: Unexpected value 'null', took 5.335s
2025-10-20T21:55:47.5310440Z [error] Test io.unitycatalog.spark.TableReadWriteTest.testCredentialCreateDeltaTable failed: io.unitycatalog.client.ApiException: java.net.ConnectException, took 2.258s
2025-10-20T21:55:49.8700854Z [error] Test io.unitycatalog.spark.TableReadWriteTest.testCredentialCreateDeltaTable failed: io.unitycatalog.client.ApiException: java.net.ConnectException, took 2.337s
2025-10-20T21:55:52.2313042Z [error] Test io.unitycatalog.spark.TableReadWriteTest.testCreateExternalDeltaTable failed: io.unitycatalog.client.ApiException: java.net.ConnectException, took 2.359s

Signed-off-by: Zheng Hu <[email protected]>
private OptionsUtil() {
}

public static final String URI = "uri";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to make a note that that is is not the full configuration key


import java.util.Map;

public class OptionsUtil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tdas tdas left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tdas
tdas merged commit 1c81361 into unitycatalog:main Oct 21, 2025
timothyw553 pushed a commit to timothyw553/unitycatalog that referenced this pull request Oct 24, 2025
…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]>
openinx added a commit to openinx/unitycatalog that referenced this pull request Nov 11, 2025
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants