bacalhau-project / bacalhau

Compute over Data framework for public, transparent, and optionally verifiable computation
https://docs.bacalhau.org
Apache License 2.0
675 stars 88 forks source link

Generate events when nodes are approved/rejected #3772

Open rossjones opened 5 months ago

rossjones commented 5 months ago

When nodes are approved or rejected, or connected/disconnected, the system may want to respond to these events by creating new evaluations, or cancelling previous tasks.

This PR adds an event emitter which allows implementations of NodeEventHandler to receive events that are one of:

NodeEventApproved
NodeEventRejected
NodeEventDeleted
NodeEventConnected
NodeEventDisconnected

all events are delivered in a goroutine, and so it is the recipients responsibility to handle the event quickly, or to create a new goroutine and return immediately.

Currently this PR delivers events to an event listener in the manager package which currently logs that it has received and event. In future, we will want to modify this behaviour to create new evaluations, or stop current executions based on the node info that is delivered with the event, the job types currently deployed, and the type of event. To enable this, the NodeEventListener is provided with a reference to the evaluation broker and the jobstore.

coderabbitai[bot] commented 5 months ago

[!IMPORTANT]

Auto 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.


Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
frrist commented 5 months ago

@rossjones I have implemented a fix for the NodeInfo overwrite bug here: https://github.com/bacalhau-project/bacalhau/pull/3785 It was a very large mechanical change to make and sadly touched a lot of files. If it looks good to you, could we land your change (this PR) after it to avoid conflicts? I suspect it will be easier to resolved conflicts from your change here than the other way around. However if you spot any significant issues with https://github.com/bacalhau-project/bacalhau/pull/3785 go ahead and merge this and I'll sort the conflicts on my end.

wdbaruni commented 5 months ago

@frrist are you owning this PR now? what do we need to do to unblock it and merge it?

frrist commented 5 months ago

@wdbaruni yeah I can take this over.