Skip to content

Volumes of jobs and pre_start hooks are not checked: undefined named volumes and duplicate targets load silently #982

Open

Description

@ndeloof

This issue was filed by an AI agent on a human's behalf. The human submitter may not have independently verified the report.

Problem

The consistency checks of the loader on the volumes of a service are not applied to the volumes of the jobs and of the pre_start hooks, which are containers with the same volumes attribute.

Reproduced on main (6ac9323):

services:
  a:
    image: alpine
    volumes: [nope:/d]            # rejected: service "a" refers to undefined volume nope
    pre_start:
      - image: alpine
        volumes: [nope:/d]        # loads without error
jobs:
  j:
    image: alpine
    triggers: {manual: true}
    volumes: [nope:/d]            # loads without error

The same goes for two entries with the same target in the volumes of a hook: the project loads, with both entries, whereas the "target already mounted" check of loader/validate.go rejects it for a service (the engine then fails at container creation instead).

Where

loader/validate.go, checkConsistency: the undefined volume and the duplicate target checks only run in the project.Services loop.

Expected

The same checks for the volumes of jobs and hooks, so that an invalid configuration is rejected when it is loaded. The mounts attribute proposed in #979 follows volumes here, and would benefit from the same fix.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions