fix: Check container_name on the rolled service #100

Merged
ahmad merged 1 commit from feature/99-container-name-own-block into main 2026-10-10 06:11:03 +00:00
Owner

Issue

Closes #99

Problem

docker compose config <service> also renders the services it depends on. So rihla's rolled api, which has no container_name, was refused because its dependency migrate keeps rihla-migrate-1. Rihla deploy run 887 failed this way before touching any container. This blocks suhba/rihla#417.

Solution

Read the full rendered config and look for container_name only inside the rolled service's own block (awk over the services: section).

Review notes

  • New kill case: a dependency with a fixed name no longer refuses the rolled service. The existing refusal case still passes.
  • On rihla's real compose on the VPS, the check reports api: none; migrate and web: has container_name.
  • Also fixed: the old | grep -q under pipefail could SIGPIPE the producer and silently skip the refusal. Against the old code, the existing refusal case fails in the harness for exactly that reason. awk reads all of its input.

Risks and trade-offs

It relies on compose's rendered layout: services at 2 spaces, their keys at 4. That is the stable config output format.

### Issue Closes #99 ### Problem `docker compose config <service>` also renders the services it depends on. So rihla's rolled api, which has no `container_name`, was refused because its dependency `migrate` keeps `rihla-migrate-1`. Rihla deploy run 887 failed this way before touching any container. This blocks suhba/rihla#417. ### Solution Read the full rendered config and look for `container_name` only inside the rolled service's own block (awk over the `services:` section). ### Review notes - New kill case: a dependency with a fixed name no longer refuses the rolled service. The existing refusal case still passes. - On rihla's real compose on the VPS, the check reports api: none; migrate and web: has container_name. - Also fixed: the old `| grep -q` under `pipefail` could SIGPIPE the producer and silently skip the refusal. Against the old code, the existing refusal case fails in the harness for exactly that reason. awk reads all of its input. ### Risks and trade-offs It relies on compose's rendered layout: services at 2 spaces, their keys at 4. That is the stable `config` output format.
fix: Check only the rolled service for container_name
All checks were successful
PR / validate (pull_request) Successful in 29s
6e2ef93e00
config <service> also renders the service's dependencies, so a rolled
api depending on a fixed-name migrate was refused. The check now reads
the service's own block. It also no longer pipes into grep -q, which
under pipefail could end the producer early and skip the refusal.
ahmad_bot requested changes 2026-10-10 06:09:52 +00:00
Dismissed
ahmad_bot left a comment

Blocking

  • PR title and commit subject are 53 characters, not 50; the limit is 50 and the squash takes the title. E.g. fix: Check container_name on the rolled service (46).

Verified at 6e2ef93 (CI PR / validate green, head contains main a1086d1):

  • The awk reads the whole rendered config, scopes to the services: section, tracks the current 2-space key and sets found only on a 4-space container_name: under the rolled service's own block; END { exit !found } makes the refusal branch run exactly when found. Keys outside services: (the stub's networks.default.container_name) and dependencies' names no longer count. No grep -q, so nothing ends the producer early under pipefail.
  • Harness on the head: all cases pass. With the old config <service> | grep -q put back, "a rolled service with container_name is refused" fails, as the description says: mail's name matches first, grep -q exits, the stub's next echo dies of SIGPIPE and the pipeline reads as "not found". With the old check kept but reading its whole input (grep … > /dev/null), the new case "a dependency's container_name does not refuse the rolled service" fails, together with "opted in: only the other services are recreated". The two cases pin both bugs.
  • Both #99 criteria are covered by those cases: a dependency's fixed name lets the swap proceed, the rolled service's own fixed name is still refused and named.
  • One subject, no trailers.

Approval on the renamed head.

**Blocking** - PR title and commit subject are 53 characters, not 50; the limit is 50 and the squash takes the title. E.g. `fix: Check container_name on the rolled service` (46). **Verified** at 6e2ef93 (CI `PR / validate` green, head contains main a1086d1): - The awk reads the whole rendered config, scopes to the `services:` section, tracks the current 2-space key and sets `found` only on a 4-space `container_name:` under the rolled service's own block; `END { exit !found }` makes the refusal branch run exactly when found. Keys outside `services:` (the stub's `networks.default.container_name`) and dependencies' names no longer count. No `grep -q`, so nothing ends the producer early under `pipefail`. - Harness on the head: all cases pass. With the old `config <service> | grep -q` put back, "a rolled service with container_name is refused" fails, as the description says: `mail`'s name matches first, `grep -q` exits, the stub's next `echo` dies of SIGPIPE and the pipeline reads as "not found". With the old check kept but reading its whole input (`grep … > /dev/null`), the new case "a dependency's container_name does not refuse the rolled service" fails, together with "opted in: only the other services are recreated". The two cases pin both bugs. - Both #99 criteria are covered by those cases: a dependency's fixed name lets the swap proceed, the rolled service's own fixed name is still refused and named. - One subject, no trailers. Approval on the renamed head.
ahmad changed title from fix: Check only the rolled service for container_name to fix: Check container_name on the rolled service 2026-10-10 06:10:05 +00:00
ahmad force-pushed feature/99-container-name-own-block from 6e2ef93e00
All checks were successful
PR / validate (pull_request) Successful in 29s
to c06584646d
All checks were successful
PR / validate (pull_request) Successful in 19s
2026-10-10 06:10:07 +00:00
Compare
ahmad_bot approved these changes 2026-10-10 06:10:50 +00:00
ahmad_bot left a comment

Re-review of c065846 after 1714.

  • Title and commit subject are now 47 characters; the blocker is resolved.
  • The diff is byte-identical to the one reviewed at 6e2ef93 (index lines aside), so the verification there stands: awk scoped to the rolled service's own block, whole input read, harness green on the head, both mutants killed by the pair of cases.
  • CI PR / validate green at c065846; one commit, no trailers.

APPROVED.

Re-review of c065846 after 1714. - Title and commit subject are now 47 characters; the blocker is resolved. - The diff is byte-identical to the one reviewed at 6e2ef93 (index lines aside), so the verification there stands: awk scoped to the rolled service's own block, whole input read, harness green on the head, both mutants killed by the pair of cases. - CI `PR / validate` green at c065846; one commit, no trailers. APPROVED.
ahmad merged commit af78e9a891 into main 2026-10-10 06:11:03 +00:00
ahmad deleted branch feature/99-container-name-own-block 2026-10-10 06:11:04 +00:00
Sign in to join this conversation.
No description provided.