fix: deploy-vps arms a monitoring profile the compose file may not declare #39
Labels
No labels
priority/P0
priority/P1
priority/P2
priority/P3
size/L
size/M
size/S
size/XL
size/XS
state/done
state/in-progress
state/in-review
state/needs-refinement
state/ready
type/bug
type/chore
type/feature
type/refactor
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
amtronics/platform-actions#39
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
deploy-vpsdecides whether to arm the monitoring profile from the credentials it wasgiven, not from the compose file it is deploying. When the Grafana variables are
present it sets
COMPOSE_PROFILES=monitoringand runsdocker compose up.Compose does not treat an unknown profile as an error. It selects the services carrying
that profile, finds none, and starts the rest normally — exit code 0, deploy reported
healthy. The result is a deployment that looks fully monitored and emits nothing, which
surfaces later as a not-reporting alert firing forever against a healthy service. That is
the worst shape a failure can take: silent at the moment it happens, and misattributed
when it is finally noticed.
This was hit for real in
ahmad/imamah(its #134): one of two compose variants declaredthe collector and the other did not, and the deploy armed the profile against both. That
instance is fixed in that repository. The action still has the hole, for every repository
that uses it.
Scope
deploy-vpsrefusing to arm a profile the target compose file does not declare, andsaying so.
monitoring; the imamahfix, already done.
Acceptance criteria
monitoringprofile, when thedeploy runs with the Grafana credentials present, then it fails with a message naming
the profile and the compose file — rather than starting the remaining services.
credentials present, then it arms it exactly as it does today.
and the check does not run.
covered.
Notes
docker compose config --profileslists the profiles a compose file declares, which isenough to make this a two-line guard rather than a parser.
Whether the mismatch should fail the deploy or only warn loudly is worth a moment's
thought: failing is right if a monitored deploy is a requirement, and wrong if some targets
are legitimately unmonitored while sharing credentials. The criteria above assume failing,
because the alternative is what produced the silent case; say so on this issue if that
assumption is wrong for some target.
Taking this. One file,
deploy-vps/action.yml.Where the check goes, and why not where the bug is. The profile is armed locally, from the credentials alone. The obvious fix is to check the compose file there — but the only reliable way to ask "which profiles does this file declare" is
docker compose config --profiles, and the action's local steps cannot assume a docker CLI inside the job container. Grepping YAML forprofiles:would be dependency-free and wrong in both directions; a false negative would refuse a perfectly good deployment. So the guard goes in the remote script, immediately beforeup, where docker is guaranteed and the real parser is available. It reads theCOMPOSE_PROFILESthe .env already carries and compares it against the declared set.The failure is loud rather than silent, which is the whole point. Compose treats an unknown profile as selecting nothing and still exits 0, so today an app whose compose does not declare
monitoringdeploys, reports success, and collects nothing — while its absent-metrics alert fires against a healthy service. That isahmad/imamah#134generically.A problem with the fourth criterion, which is mine. I wrote "when the action's tests run, then all three cases are covered" — but this repository has no behavioural test harness for actions.
check-actions.pyparses eachaction.ymland runsbash -nover therun:bodies; it cannot execute one. So I will verify the three cases by extracting the guard and driving it against a stubdocker compose— the same method used on the last few changes here — and say plainly that the criterion is met by verification rather than by a committed test. Building an action-test harness is a real gap and deserves its own issue rather than being smuggled in here.