LuciferYang commented on code in PR #14407:
URL: https://github.com/apache/gravitino/pull/14407#discussion_r4581479445
##########
catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java:
##########
@@ -1473,7 +1487,7 @@ FileSystem getFileSystemWithCache(Path path, Map<String,
String> conf) {
String authority =
provider != null ? provider.getFullAuthority(path, conf) :
path.toUri().getAuthority();
return fileSystemCache.get(
- new FileSystemCacheKey(scheme, authority),
+ new FileSystemCacheKey(scheme, authority, loginSettings(path, conf)),
Review Comment:
Reproduced. On a miss, the file system task now builds one Hadoop
configuration, checks that it resolves to the login settings in the key, and
creates the proxy from that same configuration, so the proxy no longer reads
`config.resources` again. The proxy's read of these files stays under the
connection timeout, as before; resolving the settings of a new or expired
configuration still reads them on the request thread, as I wrote earlier. If
the files changed since the settings were cached, the lookup drops the cached
settings and tries once more; a second mismatch fails with the path.
`testFileSystemCacheKeyHoldsLoginSettingsOfNewFileSystem` edits the XML before
a second user's client is created and checks that the client logs in with the
new principal and is cached under it.
`testHdfsFileSystemLogsInWithTheGivenConfiguration` checks that the
configuration reaches the proxy.
##########
catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/HDFSFileSystemProxy.java:
##########
@@ -195,15 +246,24 @@ private UserGroupInformation initKerberosUgi(
.checkIntervalSec(kerberosConfig.getCheckIntervalSec())
.krb5Conf(Constants.HADOOP_KRB5_CONF,
Constants.SECURITY_KRB5_ENV)
.build();
+ // One file for each proxy: another proxy for the same entity would
rewrite a shared file
+ // while this one still renews its ticket from it. close() deletes it;
File.deleteOnExit
+ // would keep the path of every proxy ever created until the JVM exits.
String keytabPath =
- String.format(GRAVITINO_KEYTAB_FORMAT,
properties.getOrDefault(GRAVITINO_ID_KEY, ""));
+ String.format(
+ GRAVITINO_KEYTAB_FORMAT,
+ properties.getOrDefault(GRAVITINO_ID_KEY, "") + "-" +
UUID.randomUUID());
+ File destination = new File(keytabPath);
+ // Recorded before the fetch, so that close() also deletes what a failed
fetch leaves behind.
+ this.keytabFile = destination;
File keytabFile =
- KerberosAuthUtils.saveKeytabFromUri(
+ KerberosAuthUtils.fetchKeytabFromUri(
Review Comment:
Fixed. If wrapping fails, `getProxy()` closes the underlying file system,
stops the ticket refresh and deletes the keytab file, then rethrows the
wrapping error. `testFailedWrappingReleasesFileSystemAndLogin` uses a final
`FileSystem` class, and `testFailedWrappingReleasesLoginWhenClosingFails` one
whose `close()` also throws. A proxy created after `executeFileSystemTask`
timed out was leaked the same way; the task now closes a result its caller
stopped waiting for (`testFileSystemCreatedAfterTimeoutIsClosed`). Keytab files
of proxies that are never closed are deleted when the JVM exits normally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]