Skip to content

fix(apps): give each dev session its own template names - #683

Draft
justinwlin wants to merge 1 commit into
mainfrom
fix/dev-template-name-reuse
Draft

justinwlin wants to merge 1 commit into
mainfrom
fix/dev-template-name-reuse

Conversation

@justinwlin

Copy link
Copy Markdown
Contributor

rp flash dev fails when you start the same app again soon after a session:

Error: endpoint template names must be unique. check that you do not already have an endpoint with a similar template.

Cause. Dev endpoint names are fixed per app and resource (so a session can adopt its own leftovers), and each endpoint's bound template took the same name. When a session ends, it deletes its endpoints, but the platform keeps a deleted endpoint's template until its last worker is billed, up to about 90 minutes. A new session's create collides with that held template.

Fix. Each DevSession names its bound templates <endpoint name>-<token>, with one random token per session.

  • Endpoint names don't change, so adoption still finds leftover endpoints.
  • Refreshes within a session reuse the session's name.
  • Adopting an endpoint renames its template to the new session's name. A saveEndpoint update with a new template name renames the same bound template (same templateId), checked live.

Setting template.name routes dev saves through GraphQL. Traced live sessions already used GraphQL, and the REST path would name the template <endpoint name>-template, which is just as fixed.

How I tested

  • 4 new tests in tests/test_apps/test_dev.py: the payload carries the name, two sessions get different names for one endpoint, refresh keeps the name, adoption renames. All 4 fail on main and pass with the fix.
  • make test-coverage: 2358 passed, coverage 93.80%.
  • black --check passes on runpod/apps/dev.py. tests/test_apps/test_dev.py already has black diffs on main; the new tests add none.
Live proof (2026-11-04)

A one-function CPU app (App("devtpl-repro"), @app.queue(cpu="cpu3c-1-2")), run with rp flash dev tiny.py --once and a wrapper that logs each saveEndpoint call.

main, run 1 then run 2 right after:

TRACE GQL saveEndpoint name=dev-devtpl-repro-ping-d5d64b template.name=dev-devtpl-repro-ping-d5d64b
ping ok
✓ cleaning up 1 deleted

TRACE GQL saveEndpoint name=dev-devtpl-repro-ping-d5d64b template.name=dev-devtpl-repro-ping-d5d64b
Error: endpoint template names must be unique. check that you do not already have an endpoint with a similar template.

This branch, two runs back to back (the first one while main's template above was still held):

TRACE GQL saveEndpoint name=dev-devtpl-repro-ping-d5d64b template.name=dev-devtpl-repro-ping-d5d64b-4cb5a3
ping ok
✓ cleaning up 1 deleted

TRACE GQL saveEndpoint name=dev-devtpl-repro-ping-d5d64b template.name=dev-devtpl-repro-ping-d5d64b-cb77a6
ping ok
✓ cleaning up 1 deleted

deleteTemplate on a held template returns: "Template is still held by deleted endpoint …, which is pending cleanup. It can be deleted once that endpoint's last worker has been billed, within about 90 minutes of the endpoint delete." Held templates disappear on their own after that, so per-session names don't accumulate.

Template rename on update (CPU endpoint, 0 workers, deleted after):

Step templateId template name
create with …-a s6ryk8e2oh …-a
update with …-b s6ryk8e2oh …-b
update with …-a s6ryk8e2oh …-a

rp flash dev failed with "endpoint template names must be unique" when
the same app started again soon after a session. Dev endpoint names are
fixed per app and resource, and their bound templates took the same name.
A deleted endpoint keeps its template for up to about 90 minutes, so the
next session's create collided with it.

Each session now names its bound templates <endpoint name>-<token>.
Endpoint names stay fixed so adoption still works, refreshes reuse the
session's name, and an adopted endpoint's template is renamed.

This branch has not been deployed

No deployments
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.

1 participant