Skip to content

fix(agent): deploy-app stops on a guessed app name, --new-app adds one on purpose (#57) - #368

Merged
vsilent merged 2 commits into
devfrom
fix/deploy-app-unknown-name-57
Nov 20, 2026
Merged

vsilent merged 2 commits into
devfrom
fix/deploy-app-unknown-name-57

Conversation

@vsilent

@vsilent vsilent commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

What happened

On a recorded walkthrough, deploy-app took down a running app and left a
container nothing in the product could reach (BUGS.md #57).

  1. stacker agent apps printed the app as hello.
  2. stacker agent deploy-app hello … answered no such service: hello, and
    named no alternative - the compose on the server calls that service app.
  3. The only other visible name was app, so that was tried.
  4. The agent names the remote stack's directory, and therefore its compose
    project, after the app code it is handed. A second compose project came
    up beside the running one, could not see or replace it, and failed with
    Bind for 0.0.0.0:3000 failed: port is already allocated. The original
    container was now an orphan of a project nothing addresses - every platform
    container operation is keyed by app_code
    (src/mcp/tools/monitoring.rs:721), so clearing it took docker rm -f
    over SSH, during a recording whose premise is not needing SSH.

What this changes

The problem is not the unknown name - deploy-app <new-name> is how you add
a service - it is arriving at one by guessing. So the command asks instead of
refusing:

'app' is not an app of this deployment. Apps here: hello.
Deploying an unknown name adds a second stack on the server beside the running
one; the two cannot replace each other and will fight over the same published
ports.
If you meant to update an existing app, use one of the names above -
`stacker agent apps` lists them with their images.
If you meant to add a new one, repeat the command with --new-app.

--new-app proceeds and prints which apps were already there. The check
fails open: an empty or unavailable snapshot is not evidence of a wrong
name, so a deploy it cannot judge is never blocked.

Scope

This closes the way in, not the design. The agent is still bound to a
deployment and still derives its compose project name from the app code it is
handed; #57 keeps both, with the remaining fixes in order - accept the app
code the product prints, refuse a second compose project server-side, keep the
project name stable, resolve by heartbeat, and make timeout hints name a
deployment that can answer.

A naming question worth deciding separately, raised by the same incident:
whether updating an existing app should be stacker agent update <app> with
deploy-app reserved for adding one. That is a product decision, not part of
this diff.

Tests

7 unit, 2 integration:

  • the incident's exact shape - apps = [hello], deploy app → refused, with
    the list and the reason
  • a known app passes; an empty snapshot blocks nothing
  • the refusal names every known app, and both ways out
  • --new-app allows the add
  • at the CLI level, where a unit test cannot reach: the flag parses and is
    documented in deploy-app --help

Full library suite: 2362 passed, 0 failed, 6 ignored. rustfmt clean on all
three files; clippy reports nothing in the new code (the pre-existing notes in
agent.rs are untouched).

🤖 Generated with Claude Code

robotizeit and others added 2 commits November 20, 2026 20:08
On a recorded walkthrough this cost the user their running app (BUGS.md #57).
`stacker agent apps` printed the app as `hello`; `deploy-app hello` came back
"no such service: hello" without naming anything that would work, so the only
name left to try was the one visible in the compose - `app`. That went
through, and the agent named the remote stack's directory, and therefore its
compose project, after it: a second stack came up beside the running one,
could not see or replace it, and died on `Bind for 0.0.0.0:3000 failed: port
is already allocated` while the original container was left orphaned in a
compose project nothing could reach any more.

`deploy-app` now reads the deployment's apps before sending anything and
stops on a name that is not among them, naming the ones that are and saying
why it stopped:

    'app' is not an app of this deployment. Apps here: hello.
    Deploying a name the deployment does not know would create a second stack
    on the server beside the running one, and the two would fight over the
    same ports - so this stops here.

It fails open: an empty or unavailable snapshot is not evidence of a wrong
name, so the check stays out of the way rather than blocking a deploy it
cannot judge.

This closes the way in, not the underlying design - the agent is still bound
to a deployment and still takes its compose project name from the app code
it is handed. #57 keeps both, with the fixes in order.

Tests: 5, including the exact shape of the incident (apps = [hello], deploy
`app` → refused), a known app passing, an empty list not blocking, every
known app appearing in the refusal, and entries without a code being ignored.
agent::tests 69 passed. rustfmt clean on the file; the one clippy note in it
(`.args(&ssh_args)`, line 2557) is pre-existing and untouched.

Co-Authored-By: Claude Opus 5 <[email protected]>
Correcting my own previous commit on this branch, which refused every name
the deployment does not know. Vasili pointed out what that breaks: adding a
service with `deploy-app <new-name>` is exactly how you add one, and a wall
there is worse than the bug it guards.

What is actually wrong is not the unknown name, it is arriving at it by
guessing - which is what happened in #57, after `no such service: hello`
named no alternative. So the check now asks instead of refusing:

    'app' is not an app of this deployment. Apps here: hello.
    Deploying an unknown name adds a second stack on the server beside the
    running one; the two cannot replace each other and will fight over the
    same published ports.
    If you meant to update an existing app, use one of the names above -
    `stacker agent apps` lists them with their images.
    If you meant to add a new one, repeat the command with --new-app.

With `--new-app` the deploy proceeds and prints which apps were already there,
so adding a service stays one flag away and never happens by accident.

Tests, 7 unit and 2 integration: the incident's exact shape still refused, a
known app passing, an empty snapshot not blocking, every known app named in
the refusal, both ways out named in the refusal, `--new-app` allowing the add,
and - at the CLI level, where a unit test cannot reach - that the flag is
wired and documented in `deploy-app --help`.

Full library suite: 2362 passed, 0 failed, 6 ignored. rustfmt clean on all
three files; clippy reports nothing in the new code.

Co-Authored-By: Claude Opus 5 <[email protected]>
@vsilent vsilent changed the title fix(agent): refuse deploy-app for a name the deployment does not know (#57) fix(agent): deploy-app stops on a guessed app name, --new-app adds one on purpose (#57) Nov 20, 2026
@vsilent
vsilent merged commit 3a93e09 into dev Nov 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants