Skip to content

add refresh credentials property to loadTableResult #1164

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import org.apache.iceberg.aws.AwsClientProperties;
import org.apache.iceberg.catalog.Catalog;
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.TableIdentifier;
Expand Down Expand Up @@ -397,16 +398,38 @@ public Response loadTable(
.loadTableIfStale(tableIdentifier, ifNoneMatch, snapshots)
.orElseThrow(() -> new WebApplicationException(Response.Status.NOT_MODIFIED));
} else {
response =
String credentialsEndpoint =
String.format(
"/v1/%s/namespaces/%s/tables/%s/credentials",
prefix, tableIdentifier.namespace().toString(), tableIdentifier.name());
Comment on lines +401 to +404
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be configurable. E.g., some hosts may prefix the URL with /polaris or with /your_account_name or any number of prefixes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that mean they will do something like /polaris-catalog-name instead of just /catalog-name? or I'm misunderstanding this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix identifies the catalog, does it not? Why would the .../credentials endpoint for a table in one catalog need to be under a different prefix?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Saw that #1164 (comment) got lost but think it still holds)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree the uri should be :

  public String tableCredentials(TableIdentifier ident) {
    return SLASH.join(
        "v1",
        prefix,
        "namespaces",
        RESTUtil.encodeNamespace(ident.namespace()),
        "tables",
        RESTUtil.encodeString(ident.name()),
        "credentials");
  }

LoadTableResponse originalResponse =
catalog
.loadTableWithAccessDelegationIfStale(tableIdentifier, ifNoneMatch, snapshots)
.orElseThrow(() -> new WebApplicationException(Response.Status.NOT_MODIFIED));
if (delegationModes.contains(VENDED_CREDENTIALS)) {
response =
injectRefreshVendedCredentialProperties(originalResponse, credentialsEndpoint);
} else {
response = originalResponse;
}
}

return tryInsertETagHeader(Response.ok(response), response, namespace, table).build();
});
}

private LoadTableResponse injectRefreshVendedCredentialProperties(
LoadTableResponse originalResponse, String credentialsEndpoint) {
LoadTableResponse.Builder loadResponseBuilder =
LoadTableResponse.builder().withTableMetadata(originalResponse.tableMetadata());
Comment on lines +423 to +424
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to update metadata-location too ?

loadResponseBuilder.addAllConfig(originalResponse.config());
loadResponseBuilder.addAllCredentials(originalResponse.credentials());
loadResponseBuilder.addConfig(
AwsClientProperties.REFRESH_CREDENTIALS_ENDPOINT, credentialsEndpoint);
loadResponseBuilder.addConfig(AwsClientProperties.REFRESH_CREDENTIALS_ENABLED, "true");
Comment on lines +427 to +429
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADLS also now supports creds refresh

Comment on lines +427 to +429
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check the credential type too and send this only when storage is AWS

return loadResponseBuilder.build();
}

@Override
public Response tableExists(
String prefix,
Expand Down