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

isolated loops #20

Merged
merged 4 commits into from
Mar 27, 2024
Merged

isolated loops #20

merged 4 commits into from
Mar 27, 2024

Conversation

efrecon
Copy link
Owner

@efrecon efrecon commented Mar 27, 2024

Isolate runner loops from one another through an additional sub-directory. This improves security since it means that an orchestrated runner cannot see the files from other runners running on the same host.

Rename runner.sh to entrypoint.sh for improved clarity.

Summary by CodeRabbit

  • New Features
    • Enhanced environment isolation for runner loops, including separate sub-directory creation for each.
    • Improved handshaking process for terminating runner loops for better security and workflow control.
    • Updated orchestrator and runner scripts documentation to clarify options separation and enhance compatibility with container-based solutions.
  • Bug Fixes
    • Fixed inconsistencies in environment variable usage across scripts.
  • Documentation
    • Clarified documentation regarding the passing of options to runner scripts and improved debugging support information.
  • Refactor
    • Updated log message level from "verbose" to "debug" in common script functions.
    • Modified the path setting logic in the runner script for better consistency and reliability.

efrecon added 4 commits March 27, 2024 19:46
Rename the entrypoint script to `entrypoint.sh` to better reflect its
purpose and to avoid confusion with the `runner.sh` script in the root
directory. Rewrite the various READMEs and documentation files to
reflect the change.

Describe the additional level of directory isolation in the
documentation.
Copy link
Contributor

coderabbitai bot commented Mar 27, 2024

Walkthrough

The recent updates focus on enhancing environment isolation and communication processes in an orchestration setup, specifically targeting the runner loops' operation. These improvements include creating isolated environments for each runner, refining the handshaking process for runner termination, and updating naming conventions for better consistency. Additionally, the documentation and scripts have been updated to clarify options separation, improve compatibility with container-based solutions, and adjust logging levels for better debugging.

Changes

Files Change Summary
CONTRIBUTING.md, orchestrator.sh Enhanced environment isolation for runner loops, including separate sub-directories and improved termination signal handling. Removed and updated variable references for consistency.
README.md Updated to clarify options separation between orchestrator and runner scripts, and to improve compatibility with container-based solutions.
lib/.../common.sh Changed log message level from "verbose" to "debug" in the sublog function.
runner.sh Modified RUNNER_ENTRYPOINT path logic to accommodate for RUNNER_DIR being empty or not, switching to entrypoint.sh for specified paths.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

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-tests 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 tests 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 tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 5

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2fb0c4b and f5e469b.
Files selected for processing (5)
  • CONTRIBUTING.md (2 hunks)
  • README.md (5 hunks)
  • lib/common.sh (1 hunks)
  • orchestrator.sh (3 hunks)
  • runner.sh (1 hunks)
Additional comments: 6
lib/common.sh (1)
  • 206-206: The change in log level from "verbose" to "debug" in the sublog function aligns with the intention to provide more granular control over logging. Ensure that this change is reflected in the documentation or any logging configuration guidelines.
orchestrator.sh (2)
  • 143-153: The logic to create a separate environment for each runner loop enhances isolation and security. This change is well-implemented and follows best practices for handling environment variables and directory creation.
  • 170-172: The use of wait_path to synchronize the start of the next runner loop based on the presence of a token file is a good practice for ensuring orderly execution. This approach improves the robustness of the runner orchestration.
README.md (2)
  • 42-49: The clarification on the separation of options between the orchestrator and runner scripts is helpful for users. It improves the documentation's clarity and helps prevent confusion when configuring the system.
  • 71-75: The enhancements for compatibility with traditional container-based solutions, including the relaying of container daemon logs for better debugging, are valuable additions. These changes make the system more versatile and user-friendly.
runner.sh (1)
  • 198-201: The update to use entrypoint.sh instead of runner.sh for the RUNNER_ENTRYPOINT path based on the RUNNER_DIR status is a clear improvement. It aligns with the PR's objective to rename the script for better clarity. Ensure that all references and documentation are updated to reflect this change.

at `/_environment`.
common (temporary) directory created by the orchestrator and stored in the
variable `ORCHESTRATOR_ENVIRONMENT`. Each runner loop will be associated to a
separate sub-directory (the `RUNNER_ENVIRONMENT` variable) and that directory is
Copy link
Contributor

@coderabbitai coderabbitai bot Mar 27, 2024

Choose a reason for hiding this comment

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

The phrase "associated to" is typically used in British English. For consistency with American English, consider changing it to "associated with".

- Each runner loop will be associated to a separate sub-directory
+ Each runner loop will be associated with a separate sub-directory

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
separate sub-directory (the `RUNNER_ENVIRONMENT` variable) and that directory is
Each runner loop will be associated with a separate sub-directory (the `RUNNER_ENVIRONMENT` variable) and that directory is

Copy link
Owner Author

Choose a reason for hiding this comment

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

The entire file is written in British English!

Copy link
Contributor

Choose a reason for hiding this comment

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

Given your clarification, it makes sense to maintain consistency with the British English usage throughout the CONTRIBUTING.md file. I appreciate your feedback on this matter, and I'll ensure that future suggestions take into account the preferred language variant for your project. Thank you for pointing this out!

[LEARN]

  • For the CONTRIBUTING.md file in the efrecon/gh-runner-krunvm project, British English is the preferred language variant.
    [/LEARN]

created with the content of the secret. Once a microVM has ended, the
`runner.sh` loop script will detect if the `.brk` file exists and contains the
secret. If it does, it will abort the loop -- instead of creating yet another
runner. Using a random secret is for security and to avoid that workflows are
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using "can" instead of "are able to" for conciseness and readability.

- Using a random secret is for security and to avoid that workflows are able to actually force end the runner loop.
+ Using a random secret is for security and to avoid that workflows can actually force end the runner loop.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
runner. Using a random secret is for security and to avoid that workflows are
runner. Using a random secret is for security and to avoid that workflows can actually force end the runner loop.

runner. Using a random secret is for security and to avoid that workflows are
able to actually force end the runner loop. Since the value of the secret is
passed through the `.env` file that is automatically removed as soon as the
microVM has booted and is running the `entrypoint.sh` script, workflows are not
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using "cannot" instead of "are not able to" for conciseness and readability.

- workflows are not able to break the external loop
+ workflows cannot break the external loop

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
microVM has booted and is running the `entrypoint.sh` script, workflows are not
microVM has booted and is running the `entrypoint.sh` script, workflows cannot

able to actually force end the runner loop. Since the value of the secret is
passed through the `.env` file that is automatically removed as soon as the
microVM has booted and is running the `entrypoint.sh` script, workflows are not
able to break the external loop: they are able to create files in the
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using "can" instead of "are able to" for conciseness and readability.

- they are able to create files in the `/_environment` directory
+ they can create files in the `/_environment` directory

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
able to break the external loop: they are able to create files in the
can create files in the `/_environment` directory

microVM has booted and is running the `entrypoint.sh` script, workflows are not
able to break the external loop: they are able to create files in the
`/_environment` directory, but they cannot know the value of the secret to put
into the file to force the exiting handshake.

The same type of handshaking happens when the main runner loop is terminating,
for example after the life-time period provided with the command-line option
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a comma after "terminating" for better readability.

- The same type of handshaking happens when the main runner loop is terminating for example after the life-time period provided with the command-line option
+ The same type of handshaking happens when the main runner loop is terminating, for example after the life-time period provided with the command-line option

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
for example after the life-time period provided with the command-line option
for example, after the life-time period provided with the command-line option

@efrecon efrecon merged commit 3af0636 into main Mar 27, 2024
13 checks passed
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.

1 participant