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

fix: implement NodeStore migration #4029

Merged
merged 2 commits into from
May 23, 2024
Merged

fix: implement NodeStore migration #4029

merged 2 commits into from
May 23, 2024

Conversation

frrist
Copy link
Member

@frrist frrist commented May 22, 2024

I am far from happy with this change (its a bit gross) as I had hoped to keep the number of migrations needed to a minimum. Further I had hoped to keep all migration related code tied to the repo version of the node. However, it appears we need one, and since the migration logic requires a jetstream client, which itself requires a NatsConfig it seemed simplest to renames the NodeState bucket, migrate the old one to it, and delete it.

@frrist frrist added this to the v1.3.1 milestone May 22, 2024
@frrist frrist requested a review from wdbaruni May 22, 2024 23:47
@frrist frrist self-assigned this May 22, 2024
Copy link

coderabbitai bot commented May 22, 2024

Important

Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@wdbaruni wdbaruni left a comment

Choose a reason for hiding this comment

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

First, awesome work in implementing both options to unblock the release as soon as possible. Great bias for action ;)

Overall, I am more inclined with this approach than migrating the whole repo or deleting the full node store:

  • First, it aligns more with Rethinking Configurations where the repo just a simple path and is agnostic of the content and files that different internal components are creating inside it. It is not responsible for creating those files if they don't exist, and not responsible for migrating them
  • The repo is limited to what it can do to migrate. An example is with this migration where the repo is only able to delete the whole store, while the individual component (kvstore) is able to do entry level migration
  • There will be more migrations in the future and you just laid the groundwork to simplify those future migrations. I understand with this migration the option to delete the whole kvstore is acceptable as we didn't expose the option to manually approve nodes yet, but that won't be an option in the future and we will have to do entry level migrations

I have left minor comments and you merge after addressing them

Comment on lines 109 to 111
toKV, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{
Bucket: to,
})
Copy link
Member

Choose a reason for hiding this comment

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

do we need to create the bucket first, or will this create it for us? What if the if the bucket already exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

// CreateKeyValue will create a KeyValue store with the given
// configuration.
//
// If a KeyValue store with the same name already exists and the
// configuration is different, ErrBucketExists will be returned.

My interpretation of the comment is:

  1. Create a store if it DNE
  2. Open a store if it exists with the same config
  3. Fail if the store exists, but with a different config.

And, fwiw, this is the same method we use in NewNodeStore to open/create the bucket. I think we're good here.

pkg/routing/kvstore/kvstore.go Outdated Show resolved Hide resolved
pkg/routing/kvstore/kvstore.go Outdated Show resolved Hide resolved
pkg/routing/kvstore/kvstore.go Outdated Show resolved Hide resolved
- reduce memory footrpint of migration.
- buckets are named based on version.
- extract core migration logic to method with generalize migrator
  function.
@frrist frrist merged commit 6917674 into main May 23, 2024
12 checks passed
@frrist frrist deleted the frrist/nodestore/migrate branch May 23, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

bacalhau node list returns error failed request: invalid node type: nodeTypeUndefined
2 participants