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 restored runner ID and various small enhancements #1880

Merged
merged 10 commits into from
Apr 4, 2025

Conversation

nicktrn
Copy link
Collaborator

@nicktrn nicktrn commented Apr 4, 2025

  • max dequeue run count now configurable from worker
  • worker nodetype not hardcoded
  • deterministic runner IDs and correctly updated on restore
  • run debug logs now all have runner ID and worker name

Summary by CodeRabbit

  • New Features

    • Introduced new configuration options to set limits on task processing and customize worker environments.
    • Enhanced API payloads with additional parameters that control the maximum number of runs per operation.
  • Refactor

    • Refined the mechanism for generating and updating unique runner identifiers to ensure more reliable task coordination.
    • Improved logging and initialization processes for clearer operational insights and streamlined resource management.

Copy link

changeset-bot bot commented Apr 4, 2025

⚠️ No Changeset found

Latest commit: bdf5932

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Apr 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces new environment variables and configuration options across multiple modules. It adds two new env variables, updates the initialization of components (notably in the supervisor and workload managers), and replaces static runner ID generation with a dynamic function. Several components now accept and propagate a new maxRunCount configuration. Additionally, logging improvements and type clarifications have been applied in the managed run controller. Some legacy runner ID generation constants have been removed.

Changes

File(s) Change Summary
apps/supervisor/src/env.ts Added two new environment variables: TRIGGER_DEQUEUE_MAX_RUN_COUNT (coerced integer, default 10) and KUBERNETES_WORKER_NODETYPE_LABEL (string, default "v4-worker").
apps/supervisor/src/index.ts Updated ManagedSupervisor to use env.TRIGGER_WORKER_INSTANCE_NAME for resource monitor initialization, added maxRunCount to workerSession, and commented out resource blocking.
apps/supervisor/src/util.ts, .../workloadManager/docker.ts, .../workloadManager/kubernetes.ts, packages/core/src/v3/isomorphic/friendlyId.ts Introduced a new function getRunnerId (replacing the removed RunnerId constant) and updated Docker and Kubernetes workload managers to generate runner IDs dynamically. Also, Kubernetes pods now use env.KUBERNETES_WORKER_NODETYPE_LABEL for node type.
apps/webapp/app/routes/engine.v1.worker-actions.dequeue.ts Added a new maxRunCount property to the request passed to authenticatedWorker.dequeue and reformatted import statements.
packages/cli-v3/src/entryPoints/managed-run-controller.ts Converted several imported types to use the type keyword, added TRIGGER_RUNNER_ID to the Metadata type, introduced the runnerId member in ManagedRunController, and refactored logging to use a new sendDebugLog method.
packages/core/src/v3/runEngineWorker/supervisor/queueConsumer.ts, .../schemas.ts, .../session.ts, .../workload/http.ts Added an optional maxRunCount property to queue consumer options, supervisor session, and API schema. Updated WorkloadHttpClient to include a new runnerId member with a dynamic header generator and added an updateRunnerId method.

Sequence Diagram(s)

sequenceDiagram
  participant Env as Environment
  participant MS as ManagedSupervisor
  participant WM as WorkloadManager
  participant Util as getRunnerId Function
  participant QC as QueueConsumer

  Env-->>MS: Supply TRIGGER_DEQUEUE_MAX_RUN_COUNT, TRIGGER_WORKER_INSTANCE_NAME, KUBERNETES_WORKER_NODETYPE_LABEL
  MS->>WM: Instantiate with runFriendlyId & maxRunCount config
  WM->>Util: getRunnerId(runFriendlyId)
  Util-->>WM: Return runnerId
  WM->>QC: Initialize with maxRunCount
  QC->>API: Pass maxRunCount in dequeue request
Loading

Possibly related PRs

Suggested reviewers

  • ericallam

Poem

I’m a rabbit on the run,
Hopping through code with fun,
New variables now in play,
Runner IDs light our way,
Max counts set high, not low—
Bugs beware, it’s time to go!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6efb3c and bdf5932.

📒 Files selected for processing (12)
  • apps/supervisor/src/env.ts (2 hunks)
  • apps/supervisor/src/index.ts (3 hunks)
  • apps/supervisor/src/util.ts (1 hunks)
  • apps/supervisor/src/workloadManager/docker.ts (2 hunks)
  • apps/supervisor/src/workloadManager/kubernetes.ts (3 hunks)
  • apps/webapp/app/routes/engine.v1.worker-actions.dequeue.ts (2 hunks)
  • packages/cli-v3/src/entryPoints/managed-run-controller.ts (24 hunks)
  • packages/core/src/v3/isomorphic/friendlyId.ts (0 hunks)
  • packages/core/src/v3/runEngineWorker/supervisor/queueConsumer.ts (3 hunks)
  • packages/core/src/v3/runEngineWorker/supervisor/schemas.ts (1 hunks)
  • packages/core/src/v3/runEngineWorker/supervisor/session.ts (2 hunks)
  • packages/core/src/v3/runEngineWorker/workload/http.ts (9 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@nicktrn nicktrn marked this pull request as ready for review April 4, 2025 11:31
@ericallam ericallam merged commit 7644d92 into main Apr 4, 2025
11 of 12 checks passed
@nicktrn nicktrn deleted the feat/configurable-worker-nodetype branch April 4, 2025 11:39
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.

2 participants