Skip to content

A cancel before the unit exists stops nothing #1971

Backlog

Description

@retr0h

What happens

The root broker stops the transient unit of a call or a step when the agent closes the connection, for example because its job was cancelled (Server.run calls Stop). If the agent closes the connection before systemd has created the unit, the stop finds no unit: systemctl stop exits 5, "Unit … not loaded.". systemd-run then creates the unit, and nothing stops it. The call or the step runs until its RuntimeMaxSec=, which is 5 minutes, or 30 minutes for the apt calls and the image pull and docker create steps. That is work that nobody waits for.

Since #1943 (764f368), StopUnit takes exit 5 as stopped (#1962), so this is no longer logged as an error. Before, it was an error, but the unit still ran. The gap is older than #1943.

How it was found

The code review of #1943: #1943 (comment)

Fix to evaluate

After the cancel, the broker waits until the unit exists or systemd-run returns, then stops the unit. For example: when a stop exits 5 and systemd-run still runs, try the stop again on the next tick of the watch, until systemd-run returns.

Activity

  1. added
    bug
    side-finding
    component/agent
    on Dec 6, 2026
  2. retr0h commented on Dec 6, 2026

    @retr0h
    CollaboratorAuthor

    The D-Bus rework in #1972 closes this by design.

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

    bugcomponent/agentside-finding

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions