Skip to content

feat: add volume support for job-service-run#529

Merged
CybotTM merged 4 commits into
mainfrom
feat/service-run-volumes
Mar 18, 2026
Merged

feat: add volume support for job-service-run#529
CybotTM merged 4 commits into
mainfrom
feat/service-run-volumes

Conversation

@CybotTM

@CybotTM CybotTM commented Mar 18, 2026

Copy link
Copy Markdown
Member

Summary

Closes #527 — volumes not getting mounted in job-service-run.

Adds volume config key to job-service-run, parsing Docker bind-style strings (host:container[:ro|rw]) into swarm service mounts. Supports both bind mounts and named volumes.

Example

[job-service-run "backup"]
schedule = @daily
image = postgres:15
network = cluster
volume = /host/script.sh:/script.sh
volume = backups:/backups:rw
command = /script.sh

Changes

  • core/runservice.go — add Volume []string field, parseBindMount() function, wire into buildService()
  • core/runservice_volume_test.go — 3 tests (bind mounts, named volumes, empty)
  • core/volume_parse_test.go — 6 test cases for the parser (ro, rw, named, bind, single file)
  • cli/config_decode_test.go — updated expected keys
  • Docs: jobs.md, QUICK_REFERENCE.md, packages/core.md
  • CHANGELOG updated

Test plan

  • 9 new tests (3 integration + 6 parser), all TDD
  • All existing tests pass
  • CI passes

Add Volume field to RunServiceJob, parsing bind-style strings
(host:container[:ro|rw]) into domain.ServiceMount for swarm services.
Supports bind mounts (/host:/container) and named volumes (name:/path).

Closes #527.

Signed-off-by: Sebastian Mendel <[email protected]>
Copilot AI review requested due to automatic review settings March 18, 2026 06:52
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the job-service-run functionality by enabling volume mounting. This resolves a previously identified issue where volumes were not being correctly mounted, providing greater flexibility for scheduled services to interact with persistent data or host filesystems. The change allows users to define volumes using a familiar Docker bind-style syntax, supporting both host-path bind mounts and named Docker volumes, thereby expanding the utility and integration capabilities of job-service-run within a Docker Swarm environment.

Highlights

  • New Feature: Volume Support: The job-service-run now supports a volume configuration key, allowing users to mount host directories or named volumes into service containers.
  • Docker Bind-Style Parsing: The implementation includes parsing Docker bind-style strings (e.g., host:container[:ro|rw]) into Docker Swarm service mounts.
  • Bind Mounts and Named Volumes: Both bind mounts (paths) and named volumes are supported, with options for read-only or read-write access.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

github-actions[bot]
github-actions Bot previously approved these changes Mar 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

@github-actions

github-actions Bot commented Mar 18, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

Copy link
Copy Markdown

✅ Mutation Testing Results

Mutation Score: 100.00% (threshold: 60%)

✨ Good job! Mutation score meets the threshold.

What is mutation testing?

Mutation testing measures test quality by introducing small changes (mutations) to the code and checking if tests detect them. A higher score means better test effectiveness.

  • Killed mutants: Tests caught the mutation (good!)
  • Survived mutants: Tests missed the mutation (needs improvement)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces volume support for job-service-run, a valuable feature enhancement. The implementation is well-structured, including a new parser for Docker-style volume strings, configuration updates, documentation, and a solid suite of tests. My primary feedback focuses on improving the robustness of the new volume string parser. The current implementation lacks input validation, which could lead to runtime errors with unhelpful messages for malformed volume strings. I've provided a suggestion to incorporate validation and error handling to make the feature more reliable and user-friendly. Overall, this is a great contribution that effectively addresses the feature request.

Comment thread core/runservice.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds volume mount support to job-service-run so Swarm one-shot services can mount host paths and named volumes, aligning behavior with job-run and addressing #527.

Changes:

  • Add Volume []string to core.RunServiceJob and wire mounts into the generated Swarm service spec.
  • Introduce a mount-string parser and add unit/integration tests covering bind mounts, named volumes, and empty cases.
  • Update docs, quick reference, config decoding expectations, and changelog to reflect the new volume key.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
docs/packages/core.md Updates package docs to list Volume as supported for RunServiceJob.
docs/jobs.md Documents new job-service-run volume key, including INI/label usage.
docs/QUICK_REFERENCE.md Adds volume to the job-service-run quick reference snippet.
core/runservice.go Adds Volume field, appends mounts in buildService, and introduces parseBindMount.
core/runservice_volume_test.go Verifies volumes are converted into ContainerSpec.Mounts during service creation.
core/volume_parse_test.go Unit tests for mount-string parsing (bind vs named, ro/rw).
cli/config_decode_test.go Adds volume to known keys for job-service-run.
CHANGELOG.md Notes the new volume support under Unreleased.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread docs/jobs.md Outdated
Comment thread core/runservice.go Outdated
Comment thread core/runservice.go Outdated
Comment thread core/runservice.go Outdated
- Rename parseBindMount → parseVolumeMount (handles both bind and named)
- Add input validation: error on empty/malformed volume strings
- Handle relative paths (./data, ../config) as bind mounts
- Clarify docs: format is source:target[:ro|rw], not full docker -v
- Add 7 new test cases: relative paths, invalid inputs

Signed-off-by: Sebastian Mendel <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

github-actions[bot]
github-actions Bot previously approved these changes Mar 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

Fix parseVolumeMount using strings.Contains("ro") which would false-
positive on strings like "prometheus". Now splits options by comma and
checks for exact "ro" token.

Add tests for:
- ro substring false positive (/prometheus:/data:rw must be rw)
- buildService error propagation on invalid volume string

Signed-off-by: Sebastian Mendel <[email protected]>
github-actions[bot]
github-actions Bot previously approved these changes Mar 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

Replace dynamic fmt.Errorf with wrapped ErrInvalidVolume sentinel to
satisfy the err113 linter rule.

Signed-off-by: Sebastian Mendel <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

@CybotTM CybotTM added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit 9b90d30 Mar 18, 2026
29 checks passed
@CybotTM CybotTM deleted the feat/service-run-volumes branch March 18, 2026 08:01
@github-actions github-actions Bot added the released:v0.21.5 Included in v0.21.5 release label Mar 18, 2026
@github-actions

Copy link
Copy Markdown

🚀 Released in v0.21.5

Thank you for your contribution! 🙏

This is now available in the latest release. Please test and verify everything works as expected in your environment.

If you encounter any issues, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released:v0.21.5 Included in v0.21.5 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Volumes not getting mounted

2 participants