Skip to content

charly service status exits non-zero on a healthy deployment that declares a one-shot service #1271

Backlog

Description

@aitrawog

Category

category:delivery

Type

type:fix

Remedy / files the remedy will touch

candy/plugin-pod/command.go (the charly service status exit-code path) and its tests — exempt image-declared one-shot services from the aggregate verdict, and make the printed tool exit and charly's own exit agree.

Cited design decision or org-rulebook rule (or none)

none — a CLI verb's exit-code contract is not covered by a D-id or a rulebook rule; cited behavior is /charly-core:service's documented supervisorctl-exit-3 note.

What happens

charly service status <image> exits non-zero on a deployment where every long-running service is healthy, because the image declares a ONE-SHOT service that has finished.

Measured 2026-11-24 against a live immich-cdi deployment (image ghcr.io/opencharly/immich-cdi:2026.328.1448, built from distro-cachyos/box/immich-cdi at pin pod-immich v2026.327.0043):

$ charly service status immich-cdi
dbus                             RUNNING   pid 51, uptime 0:23:35
immich-db-init                   EXITED    Nov 24 03:13 PM
immich-ml                        RUNNING   pid 61, uptime 0:23:35
immich-server                    RUNNING   pid 56, uptime 0:23:35
postgresql                       RUNNING   pid 52, uptime 0:23:35
redis                            RUNNING   pid 54, uptime 0:23:35
charly: error: command "service": exit code 3
$ echo $?
1

The EXITED row is BY DESIGN and the image says so: the same live-check run that exercises this deployment passes the step that declares it —

PASS  check immich-db-init is declared as a one-shot service that must exit 0  [immich-db-init-declared]

and the same deployment's authoritative gate is fully green (charly check live immich-cdi → 80 steps: 65 passed, 0 failed, 15 skipped), including immich-ml-service-running, immich-http-ping (status=200) and immich-ml-internal-ping.

Why it matters

A status verb's exit code is its scriptable verdict. charly service status immich-cdi && echo healthy reports failure on a healthy deployment, so no script can use the verb as a gate, and an operator reading a non-zero exit is told to look for a fault that is not there. The charly status tool probe already neutralizes exactly this: /charly-core:service records that "supervisorctl status exits with code 3 when any service isn't RUNNING … the probe's Snippet ends with || true", and classifies the output instead. The standalone verb has no such exemption and additionally prints the raw tool exit ("exit code 3") while itself exiting 1, so the two numbers disagree.

RCA

  • Expected: a healthy deployment's charly service status exits 0, or exits non-zero only for a service state that indicates a fault.
  • Actual: exit 1 (message naming the tool's exit 3) with a declared one-shot in EXITED.
  • Mechanism: the verb forwards the init tool's aggregate exit code, and the tool counts any service not currently RUNNING — a finished one-shot is not RUNNING — as failure. The image's one-shot declaration (immich-db-init is declared as a one-shot service that must exit 0) is not consulted when the verb computes its verdict.
  • Missed control: no arm asserts the verb's exit code on a deployment carrying a declared one-shot; the only covered shape is "all long-running services RUNNING" (which exits 0).
  • Blast radius: every deployment that declares a one-shot init service (immich-cdi here; any other image with a one-shot init/migration step), and every script that treats the verb's exit code as a health signal.
  • Root fix: exempt services the image declares as one-shots from the aggregate verdict (a one-shot that exited 0 is healthy; exited non-zero is a fault), and make the printed code and the returned code agree.

Blocking or non-blocking

Non-blocking for the deployment that surfaced it (that deployment is healthy by every other measure); the defect is the verb's verdict. Filed unclaimed.

Agent: immich-consolidation · Claude Code session 113f762e-5d70-484a-9ed9-e34c6423c926
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

Activity

  1. added
    category:delivery
    type:fix
    on Nov 24, 2026
  2. aitrawog commented on Nov 25, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    Reconnaissance for the fix, so the next run does not re-derive it.

    charly service status builds supervisorctl status in candy/plugin-pod/pod_cmd.go (ServiceStatusCmd.Run) and forwards it through hostPodLifecycle("service", …) → the pod-lifecycle HostBuild seam. The verb's verdict is therefore the raw supervisorctl exit code, and supervisorctl status exits 3 whenever any process is not RUNNING — which an image-declared one-shot is by design once it has finished.

    The blocker for the obvious fix: spec.PodLifecycleReply carries only ExitCode (no output rows), so the plugin cannot tell which services are non-running, and therefore cannot distinguish "a one-shot finished" from "a long-running service died". Two legal shapes:

    1. Extend PodLifecycleReply with the status rows (or a NonRunning []string), and decide in ServiceStatusCmd.Run against the image's declared one-shots (deploykit.ExtractMetadata → the services whose plan step is oneshot).
    2. Decide host-side in the pod-lifecycle op="service" body, where both the output and the resolved deploy's metadata are already in scope, and return exit 0 for a status run whose only non-running services are declared one-shots — keeping the printed rows and charly's own exit code in agreement.

    Shape 2 touches the host seam but needs no wire change; shape 1 needs a schema/cue-gen change plus the decision in the plugin. Either way this is a two-layer change, not a one-line exemption, which is why it is still open.

    Next update: when the fix PR is open, or 2026-11-25, whichever comes first.

    Agent: immich-consolidation · Claude Code session 113f762e-5d70-484a-9ed9-e34c6423c926
    Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

  3. aitrawog commented on Nov 25, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    STATUS — the fix shape is now decided from the code, not from a hunch, and it is a three-repo leg.

    What the code says (read at charly pin 2c7ffc1, plugin-pod and spec at their pins):

    • The rows are printed HOST-side: pluginDeployTarget.Shell (charly/unified_targets.go:451) prints
      reply.Output and then turns reply.ExitCode into *exitcode.ExitCodeError. The plugin never
      sees the text.
    • spec.PodLifecycleReply (spec/schema/seam.cue:1005) carries exit_code only, and its comment
      states the intent explicitly: "op-specific progress prints host-side … and failure signals via
      the error return". So today there is no way for candy/plugin-pod to judge the rows.
    • The one-shot declaration is image metadata, which only the plugin reads:
      pod-immich's immich-db-init is restart: no, start_sec: 0, exit_code: "0", and
      deploykit.ExtractMetadata exposes those fields on every meta.Service entry.

    So the decision cannot be host-side (the host has the rows but not the declaration) and cannot be
    plugin-side today (the plugin has the declaration but not the rows). The minimal honest change:

    1. spec — add output?: string to #PodLifecycleReply (CUE first, charly task cue-gen), and
      update its comment: captured stdout for op="service" too, printed by the PLUGIN so it can judge.
    2. charly — pluginDeployTarget gains a package-private capture (the dispatch reply already has
      Output); hostBuildPodLifecycle's service case returns {ExitCode, Output} and no error
      when the target can capture, keeping lt.Shell's path for targets that cannot.
    3. plugin-pod — ServiceStatusCmd.Run prints the reply's output, and on exit 3 treats the run as
      healthy iff every non-RUNNING row is a declared run-to-completion service (Restart in
      {no,false} and StartSec == 0 with an ExitCode) in EXITED state; anything else keeps the
      exit-code error. ONE predicate for "run-to-completion", used by the verb and its tests.

    Producer-first order is spec → charly → plugin-pod (plugin-pod's module pin moves in charly),
    then one umbrella wave. I am not starting it in the same change as the pin wave in flight
    (opencharly/opencharly#1274); the next session picks it up from this comment.

    Agent: immich-consolidation · Claude Code session 113f762e-5d70-484a-9ed9-e34c6423c926
    Assisted-by: Claude Code deepseek-v4.1-flash:cloud (documentation reviewed)

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

    category:deliverytype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions