Repository navigation
Add local aws credential renewal integration test. #1123
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
Changes from all commits
8289066
5cbf88e
4a80c83
1db6b78
02fbd82
45f2923
16b27ab
d416718
647bc55
19276b5
160a3e7
3b61c3f
34f62a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| package io.unitycatalog.spark.auth; | ||
|
|
||
| import io.unitycatalog.spark.UCHadoopConf; | ||
| import io.unitycatalog.spark.utils.Clock; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.sparkproject.guava.base.Preconditions; | ||
| import software.amazon.awssdk.auth.credentials.AwsCredentials; | ||
|
|
@@ -18,17 +17,11 @@ public AwsVendedTokenProvider(Configuration conf) { | |
| initialize(conf); | ||
| } | ||
|
|
||
| AwsVendedTokenProvider(Configuration conf, Clock clock, long renewalLeadTimeMillis) { | ||
| super(clock, renewalLeadTimeMillis); | ||
| initialize(conf); | ||
| } | ||
|
|
||
| @Override | ||
| public GenericCredential initGenericCredential(Configuration conf) { | ||
| if (conf.get(UCHadoopConf.S3A_INIT_ACCESS_KEY) != null | ||
| && conf.get(UCHadoopConf.S3A_INIT_SECRET_KEY) != null | ||
| && conf.get(UCHadoopConf.S3A_INIT_SESSION_TOKEN) != null | ||
| && conf.get(UCHadoopConf.S3A_INIT_CRED_EXPIRED_TIME) != null) { | ||
| && conf.get(UCHadoopConf.S3A_INIT_SESSION_TOKEN) != null) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
why is this removed?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the And I found we won't correctly initialize the The above is the code investigation. From another side, if the |
||
|
|
||
| String accessKey = conf.get(UCHadoopConf.S3A_INIT_ACCESS_KEY); | ||
| String secretKey = conf.get(UCHadoopConf.S3A_INIT_SECRET_KEY); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,6 @@ | |
| import org.sparkproject.guava.cache.CacheBuilder; | ||
|
|
||
| public abstract class GenericCredentialProvider { | ||
| // The remaining time before expiration, used to trigger renewal in advance. | ||
| private static final long DEFAULT_RENEWAL_LEAD_TIME_MILLIS = 30 * 1000; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed, because we just introduced a hadoop configuration key, so that we can also set it the test suites. That will be more convinient to do the integration testing, since for the IT, we don't have API to explicitly use the The only approach is using the |
||
|
|
||
| // The credential cache, for saving QPS to unity catalog server. | ||
| static final Cache<String, GenericCredential> globalCache; | ||
| private static final String UC_CREDENTIAL_CACHE_MAX_SIZE = | ||
|
|
@@ -31,10 +28,9 @@ public abstract class GenericCredentialProvider { | |
| globalCache = CacheBuilder.newBuilder().maximumSize(maxSize).build(); | ||
| } | ||
|
|
||
| private final Clock clock; | ||
| private final long renewalLeadTimeMillis; | ||
|
|
||
| private Configuration conf; | ||
| private Clock clock; | ||
| private long renewalLeadTimeMillis; | ||
| private URI ucUri; | ||
| private String ucToken; | ||
| private String credUid; | ||
|
|
@@ -43,18 +39,17 @@ public abstract class GenericCredentialProvider { | |
| private volatile GenericCredential credential; | ||
| private volatile TemporaryCredentialsApi tempCredApi; | ||
|
|
||
| public GenericCredentialProvider() { | ||
| this(Clock.systemClock(), DEFAULT_RENEWAL_LEAD_TIME_MILLIS); | ||
| } | ||
|
|
||
| GenericCredentialProvider(Clock clock, long renewalLeadTimeMillis) { | ||
| this.clock = clock; | ||
| this.renewalLeadTimeMillis = renewalLeadTimeMillis; | ||
| } | ||
|
|
||
| protected void initialize(Configuration conf) { | ||
| this.conf = conf; | ||
|
|
||
| // Use the test clock if one is intentionally configured for testing. | ||
| String clockName = conf.get(UCHadoopConf.UC_TEST_CLOCK_NAME); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the intentionally configured
And considering we cannot pass the |
||
| this.clock = clockName != null ? Clock.getManualClock(clockName) : Clock.systemClock(); | ||
|
|
||
| this.renewalLeadTimeMillis = conf.getLong( | ||
| UCHadoopConf.UC_RENEWAL_LEAD_TIME_KEY, | ||
| UCHadoopConf.UC_RENEWAL_LEAD_TIME_DEFAULT_VALUE); | ||
|
|
||
| String ucUriStr = conf.get(UCHadoopConf.UC_URI_KEY); | ||
| Preconditions.checkNotNull(ucUriStr, | ||
| "'%s' is not set in hadoop configuration", UCHadoopConf.UC_URI_KEY); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
| import io.unitycatalog.client.model.AzureUserDelegationSAS; | ||
| import io.unitycatalog.client.model.TemporaryCredentials; | ||
| import io.unitycatalog.spark.UCHadoopConf; | ||
| import io.unitycatalog.spark.utils.Clock; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.azurebfs.AbfsConfiguration; | ||
| import org.apache.hadoop.fs.azurebfs.extensions.SASTokenProvider; | ||
|
|
@@ -19,22 +18,14 @@ | |
| public class AbfsVendedTokenProviderTest extends BaseTokenProviderTest<AbfsVendedTokenProvider> { | ||
| @Override | ||
| protected AbfsVendedTokenProvider createTestProvider( | ||
| Clock clock, | ||
| long renewalLeadTimeMillis, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we just changed to set configuration keys in the hadoop configuration (for both As I saide above here: https://github.com/unitycatalog/unitycatalog/pull/1123/files#r2461390293 |
||
| Configuration conf, | ||
| TemporaryCredentialsApi mockApi) { | ||
| return new TestAbfsVendedTokenProvider(clock, renewalLeadTimeMillis, conf, mockApi); | ||
| Configuration conf, TemporaryCredentialsApi mockApi) { | ||
| return new TestAbfsVendedTokenProvider(conf, mockApi); | ||
| } | ||
|
|
||
| static class TestAbfsVendedTokenProvider extends AbfsVendedTokenProvider { | ||
| private final TemporaryCredentialsApi mockApi; | ||
|
|
||
| TestAbfsVendedTokenProvider( | ||
| Clock clock, | ||
| long renewalLeadTimeMillis, | ||
| Configuration conf, | ||
| TemporaryCredentialsApi mockApi) { | ||
| super(clock, renewalLeadTimeMillis); | ||
| TestAbfsVendedTokenProvider(Configuration conf, TemporaryCredentialsApi mockApi) { | ||
| initialize(conf); | ||
| this.mockApi = mockApi; | ||
| } | ||
|
|
||
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.
If we don't lower case here, then we will encounter another problem: #1121 (comment)