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

Updating behaviour of VaultsSecretsGet to align with requirements of secrets cat #805

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

aryanjassal
Copy link
Member

@aryanjassal aryanjassal commented Sep 13, 2024

Description

The current VaultsSecretsGet only gets a single secret from the vault, and returns it in the form of a UnaryHandler, meaning for large files, the RPC call will timeout. It also fetches only one file at a time, so behaviour like UNIX's cat command isn't possible.

This PR aims to fix that issue by switching over the RPC handler to a ServerHandler, supporting larger files. This PR also adds support for listing the contents of multiple files in order, like what cat does.

Issues Fixed

Tasks

  • 1. Switch UnaryHandler to StreamHandler
  • 2. Implement support for displaying contents of multiple files
  • 3. Implement support for listing multiple files across multiple vaults
  • 4. Update old test and add new tests

Final checklist

  • Domain specific tests
  • Full tests
  • Updated inline-comment documentation
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

@aryanjassal aryanjassal self-assigned this Sep 13, 2024
Copy link

linear bot commented Sep 13, 2024

@aryanjassal aryanjassal marked this pull request as draft September 13, 2024 09:45
@aryanjassal
Copy link
Member Author

I have implemented basic functionality for displaying file contents for multiple files, and updated the tests in tests/client/handlers/vaults.test.ts.

I still need to review the issue spec and all the code to ensure everything's ready for review.

@aryanjassal
Copy link
Member Author

aryanjassal commented Sep 13, 2024

MatrixAI/Polykey-CLI#243 (comment)

I'm going to go ahead with the assumption that we need to implement support for listing contents for files from multiple vaults concurrently, as that makes sense and retains consistency with UNIX commands and secrets rm.

I will wait for review of my approach from secrets rm, and if my implementation seems correct, I will implement that in secrets cat too.

@aryanjassal
Copy link
Member Author

aryanjassal commented Sep 17, 2024

The naming of secret commands has changed from what it was. The intention was to keep using the pattern of SecretsGet, SecretsPut, SecretsDel, but to better align with the new commands, these names have been changed to SecretsGet (I haven't changed this name yet), SecretsEdit, SecretsRemove.

We are kinda moving away from the pattern. This was hard to detect as this change was made one-at-a-time across multiple PRs. We might need to look into this and set a standard pattern to follow for ensuring consistency.

@aryanjassal aryanjassal marked this pull request as ready for review September 20, 2024 02:13
src/client/handlers/VaultsSecretsGet.ts Outdated Show resolved Hide resolved
src/client/types.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@tegefaulkes tegefaulkes left a comment

Choose a reason for hiding this comment

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

Small changes, just check your tests are only testing the specific condition we want.

src/client/handlers/VaultsSecretsRemove.ts Outdated Show resolved Hide resolved
tests/client/handlers/vaults.test.ts Outdated Show resolved Hide resolved
@aryanjassal aryanjassal force-pushed the feature-unix-cat branch 2 times, most recently from a1623a4 to 2ffd590 Compare September 23, 2024 05:24
@aryanjassal
Copy link
Member Author

While I am writing the tests, I can see that we use RPC calls everywhere, even when we don't need to. For example, if we are testing vaultsSecretsGet and vaultsSecretsRemove, then we will have RPC handlers for vaultsSecretsNew, vaultsSecretsMkdir, vaultsSecretsStat, etc. as other RPC handlers we use to help perform vault operations in the tests.

This introduces slowdowns as each RPC call takes time to complete. A faster method of doing the same would be to acquire a vault, and perform writeF on the vault filesystem directly. It should speed up all our tests.

@tegefaulkes and I had a chat about this, and he was also of the same opinion as I, but he mentioned how all the tests would need to be updated to ensure consistency.

How should I deal with this? Do I make a new issue tracking this? It should be relatively straightforward, so maybe this can be something @brynblack could attempt once she gets into Polykey Core development.

@tegefaulkes
Copy link
Contributor

It's some thing we can address later. I think we should make a new issue for it. It should be a general review and refactor of the vaults domain tests. I think one for the CLI and one for Polykey. You mentioned that the vaults tests is one big test file. We should look into splitting that out again but we need to check if it still crashes the CI. The other part is dealing with the vaultOps.test.ts testfile. Currently its the longest running tests by far so if we can speed it up or split it into parts that would help as well.

@tegefaulkes
Copy link
Contributor

Looks good to me.

feat: concatenates secrets from multiple vaults

feat: updated RPC handlers taking multiple secret paths to use duplex streams

chore: updated tests

chore: updated metadata assignment

chore: simplified tests

chore: separated tests for deleting directories recursively

chore: added option to continue on error
@aryanjassal
Copy link
Member Author

All tasks have been completed for this PR, all checks are passing, and reviews has also been approved. Merging.

@aryanjassal aryanjassal merged commit 57ce8d7 into staging Sep 24, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants