jerryshao commented on code in PR #13384:
URL: https://github.com/apache/gravitino/pull/13384#discussion_r4533757172
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -330,6 +331,23 @@ public LoadTableResponse updateTable(IcebergTableChange
icebergTableChange) {
return loadTable(icebergTableChange.getTableIdentifier());
}
+ /**
+ * Builds an {@link IcebergTableChange} and commits it within a single
proxied call. When this
+ * wrapper is behind the {@link KerberosAwareIcebergCatalogProxy}, the
entire operation —
+ * including the metadata.json read triggered by {@code loadTable()} inside
the builder — runs
+ * under the impersonated user's UGI context.
+ *
+ * @param builder a function that uses the underlying catalog to build an
{@link
+ * IcebergTableChange}
+ * @return the response after committing the table change
+ */
+ public LoadTableResponse buildAndUpdateTable(Function<Catalog,
IcebergTableChange> builder) {
Review Comment:
This auth fix has no test. Add a unit test with a mocked SupportsKerberos
catalog behind KerberosAwareIcebergCatalogProxy that checks the builder
function runs inside doKerberosOperations.
##########
catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/ops/IcebergCatalogWrapperHelper.java:
##########
@@ -232,6 +232,22 @@ private void alterTableColumn(
public IcebergTableChange buildIcebergTableChanges(
NameIdentifier gravitinoNameIdentifier, TableChange... tableChanges) {
+ return buildIcebergTableChanges(icebergCatalog, gravitinoNameIdentifier,
tableChanges);
Review Comment:
The old overload still loads the table with the helper's catalog outside any
impersonation, so a future caller can bring the bug back. Remove it, or mark it
test-only and say in a comment that it skips impersonation.
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -330,6 +331,23 @@ public LoadTableResponse updateTable(IcebergTableChange
icebergTableChange) {
return loadTable(icebergTableChange.getTableIdentifier());
}
+ /**
+ * Builds an {@link IcebergTableChange} and commits it within a single
proxied call. When this
+ * wrapper is behind the {@link KerberosAwareIcebergCatalogProxy}, the
entire operation —
+ * including the metadata.json read triggered by {@code loadTable()} inside
the builder — runs
+ * under the impersonated user's UGI context.
+ *
+ * @param builder a function that uses the underlying catalog to build an
{@link
+ * IcebergTableChange}
+ * @return the response after committing the table change
+ */
+ public LoadTableResponse buildAndUpdateTable(Function<Catalog,
IcebergTableChange> builder) {
+ IcebergTableChange change = builder.apply(getCatalog());
Review Comment:
Passing getCatalog() to the builder gives back the same instance the helper
already holds; the fix works only because the call runs inside the proxy. Say
this in the Javadoc so nobody later moves the builder call outside the wrapper
method.
--
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]