Skip to content
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

[#5619] feat(api): supports credential api for Gravitino #5690

Merged
merged 11 commits into from
Dec 4, 2024

Conversation

FANNG1
Copy link
Contributor

@FANNG1 FANNG1 commented Nov 27, 2024

What changes were proposed in this pull request?

This is the first PR of credential vending for Gravitino server to add credential API , please refer to #5682 for the overall workflow. Examples to use the API:

    Catalog catalog = metalake.loadCatalog(catalogName);
    Credential[] credentials =
        catalog.supportsCredentials().getCredentials();

    Credential credential =
        catalog.supportsCredentials().getCredential(“s3-token”);
    Fileset fileset = catalog.asFilesetCatalog().loadFileset(filesetIdent);
    Credential[] credentials =
        fileset.supportsCredentials().getCredentials();
    Credential credential =
       fileset.supportsCredentials().getCredential(“s3-token”);
 

Why are the changes needed?

Fix: #5619

Does this PR introduce any user-facing change?

no

How was this patch tested?

using draft PR to do E2E test

@FANNG1
Copy link
Contributor Author

FANNG1 commented Nov 27, 2024

@jerryshao @yuqi1129 please help to review this, thanks

/**
* Retrieves an array of {@link Credential} objects based on the specified credential type.
*
* @param credentialType The server will return credentials according to the configuration if
Copy link
Contributor

@yuqi1129 yuqi1129 Nov 27, 2024

Choose a reason for hiding this comment

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

You'd better give some example value of credentialType, from your description, I could not infer the possible value of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

* @throws CredentialDeserializeException If there are problems when deserializing the credential
* in client side.
*/
Credential[] getCredentials(Optional<String> credentialType)
Copy link
Contributor

Choose a reason for hiding this comment

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

So we only need parameter credentialType to abtain credentails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, is it necessary to add a more complicated parameter like CredentialRequest which contains credentialType

Copy link
Contributor

Choose a reason for hiding this comment

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

I see.

Comment on lines 34 to 37
* @return An array of {@link Credential} objects. There will be only one credential for one
* credential type. In most cases the array only contains one credential. If the object like
* {@link org.apache.gravitino.file.Fileset} contains multi locations for different storages
* like HDFS, S3, etc. The array will contain multi credentials. The array could be empty if
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. There will be only one credential for one credential type.
  2. In most cases the array only contains one credential
  3. If the object like {@link org.apache.gravitino.file.Fileset} contains multi locations for different storages

These three sentences are in conflict with each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@FANNG1
Copy link
Contributor Author

FANNG1 commented Dec 2, 2024

@jerryshao could you help to review this, thanks

@yuqi1129
Copy link
Contributor

yuqi1129 commented Dec 3, 2024

I'm fine with the current implementation.

@FANNG1
Copy link
Contributor Author

FANNG1 commented Dec 3, 2024

@jerryshao do you have time to review this PR?

* @throws NoSuchCredentialException If the specified credential type cannot be found in the
* server side.
*/
Credential[] getCredentials(Optional<String> credentialType) throws NoSuchCredentialException;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest using two interfaces:

Credentials[] getCredentials();
Credentials getCredentials(String credentialType)

The second interface can have a default implementation and be implemented based on the first one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@FANNG1
Copy link
Contributor Author

FANNG1 commented Dec 3, 2024

@jerryshao @yuqi1129 , all comments are addressed, please help to review again.

*
* @return An array of {@link Credential} objects. In most cases the array only contains one
* credential. If the object like {@link org.apache.gravitino.file.Fileset} contains multi
* locations for different storages like HDFS, S3, the array will contain multi credentials.
Copy link
Contributor

Choose a reason for hiding this comment

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

Change from "multi" to "multiple" in all the places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Credential[] getCredentials() throws NoSuchCredentialException;

/**
* Retrieves an {@link Credential} object based on the specific credential type.
Copy link
Contributor

Choose a reason for hiding this comment

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

"... based on the specified credential type."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*
* @param credentialType The type of the credential like s3-token, s3-secret-key which defined in
* the specific credentials.
* @return An {@link Credential} object with the specific credential type.
Copy link
Contributor

Choose a reason for hiding this comment

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

"... with the specified..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

"No credential found for the credential type: %s", credentialType);
} else if (credentials.length > 1) {
throw new IllegalStateException(
"Multi credentials found for the credential type:" + credentialType);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also change this multi to multiple.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@jerryshao
Copy link
Contributor

@FANNG1 can you please update the PR description to reflect your updated API?

@FANNG1
Copy link
Contributor Author

FANNG1 commented Dec 3, 2024

@FANNG1 can you please update the PR description to reflect your updated API?

done

@jerryshao jerryshao merged commit 8750ae8 into apache:main Dec 4, 2024
26 checks passed
jerryshao pushed a commit that referenced this pull request Dec 6, 2024
### What changes were proposed in this pull request?

This is the first PR of credential vending for Gravitino server to add
credential API , please refer to #5682 for the overall workflow.
Examples to use the API:

```java
    Catalog catalog = metalake.loadCatalog(catalogName);
    Credential[] credentials =
        catalog.supportsCredentials().getCredentials();

    Credential credential =
        catalog.supportsCredentials().getCredential(“s3-token”);
```

```java
    Fileset fileset = catalog.asFilesetCatalog().loadFileset(filesetIdent);
    Credential[] credentials =
        fileset.supportsCredentials().getCredentials();
    Credential credential =
       fileset.supportsCredentials().getCredential(“s3-token”);
 
```


### Why are the changes needed?

Fix: #5619 

### Does this PR introduce _any_ user-facing change?
no

### How was this patch tested?
using draft PR to do E2E test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subtask] Support credential API for Gravitino server
3 participants