mchades commented on code in PR #14407:
URL: https://github.com/apache/gravitino/pull/14407#discussion_r4565956290
##########
catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java:
##########
@@ -223,18 +231,52 @@ static class FileSystemCacheKey {
* When the path is a path without scheme such as 'file','hdfs', etc.,
then the scheme and
* authority are both null
*
- * <p>NOTE: The filesystem cache key includes the schema, authority, and
current user. Changes
- * to the configuration of the fileset will not affect the cached
filesystem.
+ * <p>NOTE: The filesystem cache key includes the scheme, authority,
current user and the
+ * authentication settings of the configuration. Changes to other
configuration of the fileset
+ * will not affect the cached filesystem.
*/
@Nullable private final String scheme;
@Nullable private final String authority;
private final String currentUser;
+ private final Map<String, String> authenticationSettings;
- FileSystemCacheKey(String scheme, String authority) {
+ FileSystemCacheKey(String scheme, String authority, Map<String, String>
conf) {
this.scheme = scheme;
this.authority = authority;
this.currentUser = PrincipalUtils.getCurrentUserName();
+ this.authenticationSettings = resolveAuthenticationSettings(conf);
+ }
+
+ /**
+ * Resolves the settings that decide how an HDFS file system logs in from
the Hadoop
+ * configuration that {@code HDFSFileSystemProxy} builds, so that values
from {@code
+ * config.resources} files and variable expansion count. The authority
carries the principal
+ * only without its realm, and a location without a scheme has no
authority at all.
+ */
+ private static Map<String, String>
resolveAuthenticationSettings(Map<String, String> conf) {
+ Configuration configuration =
+ FileSystemUtils.createCompatibleConfiguration(
+ GRAVITINO_BYPASS, additionalHDFSConfig(conf));
+ AuthenticationConfig authenticationConfig = new
AuthenticationConfig(conf, configuration);
+ Map<String, String> settings = new HashMap<>();
+ settings.put(AuthenticationConfig.AUTH_TYPE_KEY,
authenticationConfig.getAuthType());
+ settings.put(
+ AuthenticationConfig.IMPERSONATION_ENABLE_KEY,
+ String.valueOf(authenticationConfig.isImpersonationEnabled()));
+ // A catalog, schema or fileset property overrides the Hadoop value, as
in KerberosConfig.
+ settings.put(
+ KerberosConfig.PRINCIPAL_KEY,
+ conf.getOrDefault(
+ KerberosConfig.PRINCIPAL_KEY,
configuration.get(HADOOP_SECURITY_PRINCIPAL, "")));
Review Comment:
With `authentication.type=kerberos` and `hadoop.security.authentication`
left at its default, the cache key expands
`svc-${hadoop.security.authentication}@EXAMPLE.COM` to
`[email protected]`. `HDFSFileSystemProxy` sets the Hadoop property to
`kerberos` before expanding the same principal for login. I reproduced a second
fileset configured with the literal `[email protected]` reusing the first
fileset’s `[email protected]` instance. Could the cache key and the
proxy share the same login-settings resolver, with a regression test for this
pair?
##########
catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java:
##########
@@ -223,18 +231,52 @@ static class FileSystemCacheKey {
* When the path is a path without scheme such as 'file','hdfs', etc.,
then the scheme and
* authority are both null
*
- * <p>NOTE: The filesystem cache key includes the schema, authority, and
current user. Changes
- * to the configuration of the fileset will not affect the cached
filesystem.
+ * <p>NOTE: The filesystem cache key includes the scheme, authority,
current user and the
+ * authentication settings of the configuration. Changes to other
configuration of the fileset
+ * will not affect the cached filesystem.
*/
@Nullable private final String scheme;
@Nullable private final String authority;
private final String currentUser;
+ private final Map<String, String> authenticationSettings;
- FileSystemCacheKey(String scheme, String authority) {
+ FileSystemCacheKey(String scheme, String authority, Map<String, String>
conf) {
this.scheme = scheme;
this.authority = authority;
this.currentUser = PrincipalUtils.getCurrentUserName();
+ this.authenticationSettings = resolveAuthenticationSettings(conf);
+ }
+
+ /**
+ * Resolves the settings that decide how an HDFS file system logs in from
the Hadoop
+ * configuration that {@code HDFSFileSystemProxy} builds, so that values
from {@code
+ * config.resources} files and variable expansion count. The authority
carries the principal
+ * only without its realm, and a location without a scheme has no
authority at all.
+ */
+ private static Map<String, String>
resolveAuthenticationSettings(Map<String, String> conf) {
+ Configuration configuration =
+ FileSystemUtils.createCompatibleConfiguration(
Review Comment:
Every cache lookup rebuilds the Hadoop configuration and parses its XML
before checking the cache. On `file://` with an empty configuration, a warm
`getFileSystemWithCache` lookup went from about 2.7 µs on the base commit to
4.6 ms here. `listFiles` does two lookups per request. With `config.resources`,
each hit also reopens the resource outside the filesystem connection timeout.
Could we skip Kerberos resolution for non-HDFS paths and reuse the resolved
settings for repeated HDFS lookups with the same configuration?
--
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]