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

Implement repo version 4 with migration #4030

Closed
wants to merge 2 commits into from
Closed

Conversation

frrist
Copy link
Member

@frrist frrist commented May 23, 2024

frrist added 2 commits May 22, 2024 17:04
- fixes #4024
- this ensures that each time a compute node is started it attempts to
  register itself wit the requester. This is imporatant since in the
  event a requester loses it state compute nodes will re-register
  themselves with it. If they have already registered with a requester
  node registering again idempotent.
- pairing this with the parent commit regarding the V3 Migration is
  required.
@frrist frrist requested a review from wdbaruni May 23, 2024 00:13
@frrist frrist self-assigned this May 23, 2024
Copy link
Contributor

coderabbitai bot commented May 23, 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.

Comment on lines -77 to -81
if m.registrationFile.Exists() {
log.Ctx(ctx).Debug().Msg("not registering with requester, already registered")
return nil
}

Copy link
Member

Choose a reason for hiding this comment

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

Why are we removing the registration state? This means the compute node will have to re-register every time at startup and the node will fail to start if it is offline or disconnected from the requester.

Overall, I think we need to do better for node registration and allow the compute node to periodically re-check with the requester if the registration info match, and re-register if needed. So not only during startup, and should be best effort if the compute node is offline. Meaning the compute node should continue to run the locally allocated jobs even if it fails to register or re-register. I have a NodeManagerV2 placeholder for 1.5 that should track and fix most issues related to node management.

Since we don't have full offline capabilities today, it might make sense to force compute nodes to re-register at startup if we know what we are doing, and we can fix things with NodeManagerV2

Copy link
Member Author

Choose a reason for hiding this comment

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

Why are we removing the registration state?

Its a requirement for the migration added here to work since we are deleting the requester nodes nodestore. Removing this lock ensures each time a compute node is started it attempts to register itself wit the requester. This is important since in the event a requester loses it nodestate store (i.e. the migration) compute nodes will re-register themselves with it. If they have already registered with a requester node registering again idempotent.

the node will fail to start if it is offline or disconnected from the requester

True, although the compute nodes will also fail to start if starting fresh and they are unable to connect to the requester. I don't think a failure here should result in an aborted start, rather the node should continue attempting to register itself until successful (e.g. loop until success)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I understand. As I mentioned it is fine to remove the registration state for now

if err != nil {
return err
}
return os.RemoveAll(resolvedCfg.Node.Network.StoreDir)
Copy link
Member

Choose a reason for hiding this comment

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

Actually Node.Network.StoreDir gives the parent
~/.bacalhau/orchestrator_store which holds both job store and nats store. I don't recall the motivation for doing it this way.

I am also concerned that we delete something not intended if the user misconfigured this path to be something outside of the bacalhau dir and something we shouldn't delete.

If we were to go with the repo migration route instead of migrating entries, then we need to validate this path , and only delete specific sub-directories that are related to node kv store and not the whole path

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually Node.Network.StoreDir gives the parent
~/.bacalhau/orchestrator_store which holds both job store and nats store. I don't recall the motivation for doing it this way.

I don't think that is the case see https://github.com/bacalhau-project/bacalhau/blob/main/pkg/config/config.go#L87 and attached debugger screenshot.
image

We can check if the path is outside the repo, and if that is the case abort the migration, but I think the odds of that happening are next to zero.

Comment on lines +14 to +15
var V3Migration = repo.NewMigration(
repo.RepoVersion3,
Copy link
Member

Choose a reason for hiding this comment

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

please add a test scenario for this migration. We already have a test suite for repo migrations and should be trivial to add this one

Copy link
Member

Choose a reason for hiding this comment

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

also you might want to validate that migration will be graceful if the store doesn't exist or the path is not configured properly

Copy link
Member Author

Choose a reason for hiding this comment

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

Was waiting for feedback on this vs #4029 before doing any more work here. But if we decide we like this PR better I will add tests before merging.

@frrist
Copy link
Member Author

frrist commented May 23, 2024

closing in favor of alternative #4029

@frrist frrist closed this May 23, 2024
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