Repository navigation
[Server] Consolidate Iceberg FileIO behind FileOperations - #1687
Conversation
fb080f2 to
2dfdd12
Compare
| return CompletableFuture.supplyAsync(() -> TableMetadataParser.read(fileIO, metadataLocation)) | ||
| .join(); | ||
| FileIO fileIO = fileOperations.getFileIO(metadataLocation); | ||
| return TableMetadataParser.read(fileIO, metadataLocation.toString()); |
There was a problem hiding this comment.
I saw below getFileIO builds a ResolvingFileIO. here, should we be closing it by calling fileIO.close()?
or maybe something like
try (FileIO fileIO = fileOperations.getFileIO(metadataLocation)) {
return TableMetadataParser.read(fileIO, metadataLocation.toString());
}| case S3, GS, ABFS, ABFSS -> { | ||
| ResolvingFileIO fileio = new ResolvingFileIO(); | ||
| fileio.initialize(getFileIOConfig(path)); | ||
| yield fileio; | ||
| } |
There was a problem hiding this comment.
I think this needs tests
There was a problem hiding this comment.
something that lets FileOperations.getFileIO("s3://…") build a real ResolvingFileIO and read through it against the S3Mock
| String s3Region = s3BucketRegionMap.get(path.getStorageBase()); | ||
| return Map.of( | ||
| S3FileIOProperties.ACCESS_KEY_ID, awsCredentials.getAccessKeyId(), | ||
| S3FileIOProperties.SECRET_ACCESS_KEY, awsCredentials.getSecretAccessKey(), | ||
| S3FileIOProperties.SESSION_TOKEN, awsCredentials.getSessionToken(), | ||
| AwsClientProperties.CLIENT_REGION, s3Region); |
There was a problem hiding this comment.
When you call the .get(key) method on a Java Map and the key is not found, the method returns null. It does not throw an exception.
in this case s3Region may be null, right? should we add a guard before this map
| TemporaryCredentials cred = | ||
| storageCredentialVendor.vendCredential(path, Set.of(CredentialContext.Privilege.SELECT)); |
There was a problem hiding this comment.
recently I've discovered that there may be instances where deployments may actually just rely on ambient credentials for reading un-vended GCP tables. so I wonder, will that behaviour persist here?
There was a problem hiding this comment.
Yes ambient credentials on server can also be used for vending a temp table cred. This is where it is picked up for S3:
// Otherwise just defer to DefaultCredentialsProvider
credentialsProvider = DefaultCredentialsProvider.create();
| return getS3Config(path, cred.getAwsTempCredentials()); | ||
| } else { | ||
| // Cloud vend returned no recognized credential type; nothing to configure. | ||
| return Map.of(); |
There was a problem hiding this comment.
is it better to throw directly here with a clear message?
There was a problem hiding this comment.
I guess even if it's impossible, better to throw I think (up to you)
| } | ||
| Stream<Path> walk; | ||
| try { | ||
| walk = Files.walk(dirPath); |
There was a problem hiding this comment.
Files.walk(dirPath, FileVisitOption.FOLLOW_LINKS) to follow symlinks like in server/src/main/java/io/unitycatalog/server/persist/utils/FileOperations.java
There was a problem hiding this comment.
It's intentionally removed. FOLLOW_LINKS is dangerous.
timothyw553
left a comment
There was a problem hiding this comment.
Generally looks good to me
|
|
||
| private final ServerProperties serverProperties; | ||
| private final StorageCredentialVendor storageCredentialVendor; | ||
| private final Map<NormalizedURL, String> s3BucketRegionMap; |
There was a problem hiding this comment.
I understand it's the correct direction to unify all cloud storage access in a abstracted FileOperations, but seems like we are implementing all the cloud storage operations inside this FileOperations class ? ultimately I assume we will need an abstraction to fully decouple those cloud storage access into several fully isolated classes, so that one cloud won't perceive and access any other cloud resource.
There was a problem hiding this comment.
The core part of this file is the getFileIO, getFileIOConfig and get*Config functions which directly generates cloud specific FileIO objects. s3BucketRegionMap happens to be part of this process.
Other than that, all the other functions will be cloud agnostic. The abstraction is already handled by getFileIOConfig. Different cloud implementation of actual file IO is implemented by ResolvingFileIO (and its delegation).
| case FILE, NULL -> SimpleLocalFileIO.deleteDirectory(url.toString()); | ||
| // Currently we can NOT delete the path in cloud storage. We will update this in future | ||
| // when UC OSS begins using the hadoopfs libraries. | ||
| case S3 -> {} |
There was a problem hiding this comment.
Shouldn't we throw rather than silent return ?
There was a problem hiding this comment.
If it throws, deleting a managed entity on cloud would simply fail. This is incomplete and pre-existing.
| * Returns an Iceberg {@link FileIO} for reading the given location. Local paths use {@link | ||
| * SimpleLocalFileIO}; cloud paths use a credential-vended {@link ResolvingFileIO}. | ||
| */ | ||
| // TODO: Cache fileIOs |
There was a problem hiding this comment.
That's really important, otherwise, every access will exhaustively consume all the resources by creating massive fileIO instance.
There was a problem hiding this comment.
Yes. But not in this PR yet.
| case FILE, NULL -> new SimpleLocalFileIO(); | ||
| case S3, GS, ABFS, ABFSS -> { | ||
| ResolvingFileIO fileio = new ResolvingFileIO(); | ||
| fileio.initialize(getFileIOConfig(path)); |
There was a problem hiding this comment.
Actually, you can use HadoopFileIO directly to get a FileIO https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/hadoop/HadoopFileIO.java. that will automatically address your fileIO cache problem, since the FileSystem will have the cache by default.
There was a problem hiding this comment.
The downsides of using Hadoop FS (hadoop-client-runtime) is heavy dependency. It's a shaded uber-jar of an entire ecosystem that weighs ~30 MB, ~18,000 classes adding to the server runtime.
For now I don't see a good reason to adopt that yet.
| return Map.of(); | ||
| } | ||
|
|
||
| // FIXME!! privileges are defaulted to READ only here for now as Iceberg REST impl doesn't |
There was a problem hiding this comment.
If iceberg rest impl does not support vending write cred, then the IRC cannot support write for now right ?
There was a problem hiding this comment.
IRC write support is not implemented yet.
openinx
left a comment
There was a problem hiding this comment.
I skimmed this PR again, and I'm looking forward to seeing few answers from the questions:
-
Seems like we are agreed to reuse the existing iceberg
FileIOas the fundermental storage abstraction. then will we consider to use the abstracted approach to initialize the concreteFileIOinstance ? as I like to see we fully isolate those cloud vender into separate and isolated classes, rather than mixing them together, which may distract us. -
As long term we will require the server side cloud credential renewal and caching work, without the 1st abstraction and isolation, it may not clearly solve and support server-side credential renwal and caching.
Thanks for the second pass @openinx. Answers to the two questions: 1. Isolating the concrete What's centralized in 2. Server-side credential renewal + caching. Agreed, and neither is implemented in this PR (see the |
Fold FileIOFactory into FileOperations as the single entry point for storage access, including credential-vended ResolvingFileIO for cloud paths and an expanded SimpleLocalFileIO for local paths. - Move SimpleLocalFileIO from service/iceberg to persist/utils - Wire MetadataService and TableConfigService through FileOperations - Create FileOperations at server startup with StorageCredentialVendor - Remove FileOperations from Repositories and unused repository fields Signed-off-by: Yi Li <[email protected]>
Signed-off-by: Yi Li <[email protected]>
6460fc7 to
3268eee
Compare
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedDescription of changes
Fold FileIOFactory into FileOperations as the single entry point for storage access, including credential-vended ResolvingFileIO for cloud paths and an expanded SimpleLocalFileIO for local paths.