Skip to content

Add timeout for runner jobs #194

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

Merged
merged 2 commits into from
Jun 3, 2024
Merged

Add timeout for runner jobs #194

merged 2 commits into from
Jun 3, 2024

Conversation

rafaelgomesxyz
Copy link
Collaborator

@rafaelgomesxyz rafaelgomesxyz commented May 29, 2024

Fixes #193

Adds a timeout for runner jobs (6 hours by default, but configurable through runner_job_timeout in controlplane.yml), to prevent issues where an interactive job may not finish properly.

Summary by CodeRabbit

  • New Features

    • Introduced a configurable timeout feature for run jobs, with a default value of 1000 seconds, set via runner_job_timeout in controlplane.yml.
    • Added default job timeout of 6 hours and a job history limit of 10 for run commands.
  • Documentation

    • Updated documentation to reflect the new runner_job_timeout parameter and default job timeout settings.
  • Tests

    • Adjusted test scenarios to incorporate the new job timeout configuration.

@rafaelgomesxyz rafaelgomesxyz added the enhancement New feature or request label May 29, 2024
@rafaelgomesxyz rafaelgomesxyz self-assigned this May 29, 2024
Copy link

coderabbitai bot commented May 29, 2024

Walkthrough

The recent update introduces a timeout feature for run jobs, configurable via the runner_job_timeout parameter in controlplane.yml. This enhancement ensures that jobs do not run indefinitely, with a default timeout set to 6 hours. Additionally, the run command now manages job-specific parameters to prevent race conditions during concurrent job executions.

Changes

Files/Groups Change Summary
CHANGELOG.md, README.md, docs/commands.md, examples/controlplane.yml Introduced runner_job_timeout parameter with a default value of 1000 seconds for job execution time.
lib/command/run.rb Updated Run class to include job timeout and history limit settings, configurable via controlplane.yml.
spec/command/run_spec.rb Modified test commands to include single quotes around command strings for proper execution.
spec/dummy/.controlplane/controlplane.yml Added a new configuration block for dummy-test-runner-job-timeout-{GLOBAL_IDENTIFIER} with a timeout of 10.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant Runner
    participant ControlPlane

    User->>ControlPlane: Update controlplane.yml with runner_job_timeout
    ControlPlane-->>Runner: Pass configuration settings
    User->>Runner: Execute `cpl run` job
    Runner->>Runner: Apply job-specific timeout
    Note over Runner: Job runs with configured timeout
    Runner->>User: Job completion or timeout notification
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Add timeout for runner jobs (#193)
Configurable timeout via runner_job_timeout
Default timeout set to 6 hours

Poem

In the land of code, a change did sprout,
A timeout for jobs, to clear any doubt.
Six hours they run, no longer they stray,
Configured with care, to keep errors at bay.
🐇 With a hop and a leap, the rabbit did cheer,
For jobs now behave, no need to fear. 🎉


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 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.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.

Copy link
Collaborator

@dzirtusss dzirtusss left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from run-cpln-changes to main June 3, 2024 08:49
Copy link

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4b6c2e8 and d1510b4.

Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • docs/commands.md (1 hunks)
  • examples/controlplane.yml (1 hunks)
  • lib/command/run.rb (5 hunks)
  • spec/command/run_spec.rb (2 hunks)
  • spec/dummy/.controlplane/controlplane.yml (1 hunks)
Additional context used
LanguageTool
docs/commands.md

[uncategorized] ~44-~44: You might be missing the article “the” here.
Context: ...mage` - Builds and pushes the image to Control Plane - Automatically assigns image num...


[uncategorized] ~56-~56: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...uantity or are older than the specified amount of days - Specify the max quantity thro...


[grammar] ~57-~57: Possible verb agreement error. Did you mean “specifies”? (Some collective nouns can be treated as both singular and plural, so ‘Specify’ is not always incorrect.)
Context: ...der than the specified amount of days - Specify the max quantity through `image_retenti...


[uncategorized] ~58-~58: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...ne/controlplane.ymlfile - Specify the amount of days throughimage_retention_days` ...


[uncategorized] ~72-~72: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ... date of the latest image - Specify the amount of days after an app should be consider...


[uncategorized] ~230-~230: This expression is usually spelled with a hyphen.
Context: ... is only supported for domains that use path based routing mode and have a route configure...


[uncategorized] ~241-~241: This expression is usually spelled with a hyphen.
Context: ... is only supported for domains that use path based routing mode and have a route configure...


[uncategorized] ~252-~252: This expression is usually spelled with a hyphen.
Context: ... is only supported for domains that use path based routing mode and have a route configure...


[typographical] ~376-~376: Unpaired symbol: ‘"’ seems to be missing
Context: ...t is bash, in which case the args ["-c", cmd_to_run] are passed - Providing `--...


[style] ~433-~433: Consider replacing ‘only’ with a different word to let your writing stand out.
Context: ...ne/controlplane.yml` file - This should only be used for temporary apps like review ...

CHANGELOG.md

[uncategorized] ~30-~30: You might be missing the article “the” here.
Context: ...4-05-27 ### Fixed - Fixed issue where release script was not running from the app ima...


[uncategorized] ~35-~35: You might be missing the article “the” here.
Context: ...## Added - Added post-creation hook to setup-app command (configurable through...


[style] ~43-~43: To form a complete sentence, be sure to include a subject.
Context: ... non-zero code if any validation fails. Can be disabled by setting `DISABLE_VALIDAT...


[uncategorized] ~54-~54: You might be missing the article “the” here.
Context: ...4-05-15 ### Fixed - Fixed issue where cleanup-stale-apps command fails to del...


[uncategorized] ~67-~67: You might be missing the article “the” here.
Context: ...xed - Fixed race conditions when using latest image in run command. [PR 163](https:...


[uncategorized] ~67-~67: You might be missing the article “the” here.
Context: ...e conditions when using latest image in run command. [PR 163](https://github.co...


[uncategorized] ~83-~83: You might be missing the article “the” here.
Context: ...y-image` command now raises an error if image does not exist. [PR 153](https://github...


[uncategorized] ~106-~106: You might be missing the article “the” here.
Context: ..._app_name_starts_withset totrueincopy-image-from-upstream` command. [PR 1...


[uncategorized] ~118-~118: You might be missing the article “the” here.
Context: ... over config from controlplane.yml in copy-image-from-upstream command. [PR 1...


[uncategorized] ~129-~129: You might be missing the article “the” here.
Context: ...hub.com/ahangarha). - Fixed issue where delete command fails to delete apps wit...


[grammar] ~151-~151: The operating system from Apple is written “macOS”.
Context: ...-17 ### Fixed - Fixed failed build on MacOS by adding platform flag and fixed multi...


[uncategorized] ~173-~173: You might be missing the article “the” here.
Context: ...3-09-20 ### Fixed - Fixed issue where copy-image-from-upstream command does n...


[uncategorized] ~191-~191: You might be missing the article “an” here.
Context: ... run commands fail when not providing image. [PR 68](https://github.com/shakacode/c...


[uncategorized] ~199-~199: You might be missing the article “the” here.
Context: ...s://github.com/rafaelgomesxyz). - Fixed run:cleanup command for all apps that s...


[uncategorized] ~200-~200: You might be missing the article “the” here.
Context: ...s://github.com/rafaelgomesxyz). - Fixed cleanup-old-images command for all apps...


[uncategorized] ~201-~201: You might be missing the article “the” here.
Context: ...s://github.com/rafaelgomesxyz). - Fixed --help option. [PR 66](https://github.c...


[uncategorized] ~205-~205: You might be missing the article “the” here.
Context: ... - Added --use-local-token option to run:detached command. [PR 61](https://g...


[uncategorized] ~218-~218: You might be missing the article “the” here.
Context: ...1.0.1] - 2023-06-28 ### Fixed - Fixed cleanup-stale-apps command when app doe...


[uncategorized] ~218-~218: You might be missing the article “an” here.
Context: ...le-apps` command when app does not have image. [PR 55](https://github.com/shakacode/c...

README.md

[style] ~36-~36: Try using a synonym here to strengthen your writing.
Context: ...ons. Control Plane, on the other hand, gives you access to raw cloud computing power. Ho...


[uncategorized] ~63-~63: Possible missing comma found.
Context: ...iration for your own scripts. - Easy to understand Heroku to Control Plane conventions in ...


[style] ~76-~76: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ding the database and other services. - has common environment variables. On Contr...


[style] ~113-~113: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: .../en/) (required for these helpers). 4. Install Control Plane CLI, and configure access...


[grammar] ~160-~160: The word “setup” is a noun. The verb is spelled with a space.
Context: ...is.ymlandpostgres.yml`, which could setup Redis and Postgres for a testing applic...


[uncategorized] ~386-~386: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...yYWQ3MzA2NGE1YWJjNmVlMGE) for ShakaCode open source projects. ## Environment There are tw...


[uncategorized] ~390-~390: Possible missing article found.
Context: ... we can set up environment variables in Control Plane: - **In workload/container/env...


[uncategorized] ~434-~434: Possible missing article found.
Context: ...several options for a database setup on Control Plane: - Heroku Postgres. It is th...


[uncategorized] ~444-~444: Possible missing comma found.
Context: ...d provider for Postgres, e.g., Amazon's RDS can be a quick go-to. Here are [instr...

Markdownlint
docs/commands.md

5-5: null
Fenced code blocks should have a language specified


23-23: null
Fenced code blocks should have a language specified

README.md

544-544: Expected: dash; Actual: asterisk
Unordered list style


545-545: Expected: dash; Actual: asterisk
Unordered list style


546-546: Expected: dash; Actual: asterisk
Unordered list style


14-14: Expected: 1; Actual: 2
Multiple consecutive blank lines


543-543: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines


544-544: null
Lists should be surrounded by blank lines


21-21: Expected: ----; Actual: ---
Horizontal rule style


28-28: Expected: ----; Actual: ---
Horizontal rule style


128-128: null
Spaces inside code span elements


143-143: null
Fenced code blocks should have a language specified

Additional comments not posted (11)
spec/dummy/.controlplane/controlplane.yml (1)

146-151: Configuration block for dummy-test-runner-job-timeout-{GLOBAL_IDENTIFIER} added correctly.

Please verify if the timeout value of 10 is intended for testing purposes, as it deviates significantly from the default discussed in the PR summary.

examples/controlplane.yml (1)

95-98: Added runner_job_timeout parameter with a default value of 1000 seconds.

Please clarify the discrepancy between the default timeout value mentioned here (1000 seconds) and the 6 hours mentioned in the AI-generated summary.

spec/command/run_spec.rb (2)

116-116: Single quotes added around command strings in test scenarios.

This change ensures that the commands are executed as expected during tests.


208-229: New test context for runner_job_timeout added correctly.

This test verifies that the job times out as expected, aligning directly with the PR objectives.

docs/commands.md (1)

383-384: Documentation for default job timeout added correctly.

This addition is consistent with the changes made in other files and aligns with the PR objectives.

lib/command/run.rb (5)

48-49: The documentation in the long description is clear and concise about the new timeout feature.


94-95: The default values for job timeout and history limit are well-defined and follow the requirements specified in the PR.


113-114: Properly retrieves and sets the job timeout and history limit from the configuration or uses the default values if not specified.


186-193: The job specification within create_runner_workload method correctly sets the activeDeadlineSeconds and historyLimit based on the job timeout and history limit. This ensures that the job respects the configured or default timeout and maintains a history limit.


222-230: The update_runner_workload method correctly checks and updates the activeDeadlineSeconds and historyLimit if they differ from the current settings. This ensures that any changes to the timeout or history limit are applied to existing workloads.

CHANGELOG.md (1)

19-19: The changelog entry clearly documents the addition of the timeout feature for run jobs, linking to the PR and the contributor. This provides transparency and traceability for the changes made.

@rafaelgomesxyz rafaelgomesxyz merged commit 5e08d42 into main Jun 3, 2024
5 checks passed
@rafaelgomesxyz rafaelgomesxyz deleted the runner-job-timeout branch June 3, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add timeout for runner jobs
3 participants