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

Do not copy when running ephemeral runners #23

Merged
merged 3 commits into from
Mar 28, 2024
Merged

Conversation

efrecon
Copy link
Owner

@efrecon efrecon commented Mar 28, 2024

When running ephemeral runners, the default, do not copy the unpacked installation to the worker directory. Instead, run directly from there, after having changed ownership of all files recursively. Avoiding the copy speeds up the creation of new runners.

Summary by CodeRabbit

  • New Features
    • Added support for ephemeral runners through the RUNNER_EPHEMERAL flag.
    • Introduced default labels for runners via RUNNER_DEFAULT_LABELS.
  • Refactor
    • Enhanced runner installation process for ephemeral runners.
    • Improved runner configuration with dynamic RUNNER_PREFIX and RUNNER_LABELS based on the operating system distribution.

efrecon added 3 commits March 28, 2024 15:38
When not running with an environment file, only pass the ephemeral
option if it was set. This is a bugfix.
When the runner is known to be ephemeral, do not copy the content of the
runner unpacked distribution to the work directory. Instead, run from
there directly and set the RUNNER_BINROOT variable to point to the
installation directory. Ensure that the content of the variable is used
for deciding where to run the runner from and fix directory tree
ownership prior to starting the runner.

Rename the label to krun, instead of krunvm. This is to highlight the
underlying technology used, rather than how the runners are created.
This is a breaking change, but it is not expected to be used in
production yet.
Copy link
Contributor

coderabbitai bot commented Mar 28, 2024

Walkthrough

The updates focus on enhancing the flexibility and configurability of a runner script and its entrypoint. Key improvements include the introduction of conditional -e flag usage based on RUNNER_EPHEMERAL status, the addition of RUNNER_DEFAULT_LABELS for easier runner identification, and specialized handling for ephemeral runners. Adjustments were also made to runner labeling and prefix setting based on the distribution, alongside updates to binary root references, streamlining the setup and execution process for different operational contexts.

Changes

Files Change Summary
runner.sh Added conditional -e flag usage based on RUNNER_EPHEMERAL.
runner/entrypoint.sh - Introduced RUNNER_DEFAULT_LABELS for default runner labels.
- Modified runner_install for ephemeral runner handling.
- Adjusted RUNNER_PREFIX and RUNNER_LABELS based on RUNNER_DISTRO.
- Updated references to RUNNER_BINROOT.

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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0363ba6 and e7675e1.
Files selected for processing (2)
  • runner.sh (2 hunks)
  • runner/entrypoint.sh (5 hunks)
Additional comments (3)
runner.sh (1)
  • 264-266: The conditional addition of the -e flag based on RUNNER_EPHEMERAL is correctly implemented. Ensure to verify the integration with run_krunvm and the actual behavior of ephemeral runners in practice.
runner/entrypoint.sh (2)
  • 103-105: The introduction of RUNNER_DEFAULT_LABELS enhances the configurability of default runner labels, making the script more flexible. This is a positive change.
  • 409-416: Adjusting RUNNER_PREFIX and RUNNER_LABELS based on RUNNER_DISTRO is a thoughtful improvement that enhances the runner's adaptability to different environments. This change increases operational efficiency and compatibility.

Comment on lines +167 to +177
if is_true "$RUNNER_EPHEMERAL"; then
debug "Ephemeral runner: no copy made, running from $RUNNER_INSTDIR"
RUNNER_BINROOT="$RUNNER_INSTDIR"
else
if ! [ -d "${RUNNER_WORKDIR%/}" ]; then
mkdir -p "${RUNNER_WORKDIR%/}"
verbose "Created runner directory ${RUNNER_WORKDIR%/}"
fi
RUNNER_BINROOT="${RUNNER_WORKDIR%/}/runner"
verbose "Copying runner installation to $RUNNER_BINROOT"
cp -rf "$RUNNER_INSTDIR" "$RUNNER_BINROOT" 2>/dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

The modifications in runner_install to handle ephemeral runners by avoiding unnecessary copying are well-implemented and align with the objective to optimize the setup process. Consider adding comments to clarify the behavior for future maintainers.

Would you like me to add explanatory comments to this section for clarity?

@efrecon efrecon linked an issue Mar 28, 2024 that may be closed by this pull request
@efrecon efrecon merged commit 471b2f6 into main Mar 28, 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.

Prevent runner tree copy to speed up initialisation
1 participant