Wait for the old pmm-agent to exit in PMM-T2227 - #1187
Merged
Conversation
The tarball-upgrade test restarts pmm-agent with `pkill -f pmm-agent`
followed immediately by `docker exec -d pmm-agent ...`, then compares
`ps -C pmm-agent -o pid=` against the pid captured before the upgrade.
pkill returns as soon as SIGTERM is delivered, not once the process is
gone, so the replacement agent can start while the old one is still
shutting down. `ps` then lists both pids and `outNotContains(oldPid)`
fails -- reporting a restart that did happen as one that did not:
Expected substring: not " 170\n"
Received string: " 170\n 351\n"
Poll until the old pid is no longer in `ps` before starting the new
agent. The wait is bounded at 30s and fails loudly if the agent never
exits, so a genuine "pmm-agent ignores SIGTERM" regression still
surfaces instead of being masked.
Signed-off-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
travagliad
reviewed
Aug 15, 2026
travagliad
approved these changes
Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Failures fixed (investigator)
main@37a003d), jobCLI / Integration / Generic(94930840155)cli/tests/generic.spec.ts:577/@generic— PMM-T2227 "Verify tarball upgrade"What failed
The only red job in the run. Its
Run CLI testsstep is|| true, so the failuresurfaced one step later when
launchable gateexited 1 onActionable Failures | 1:170is the pid of the pmm-agent running before the tarball upgrade;351is the onestarted after it. Both were in
psat the moment the assertion read it.Root cause — a zero-margin race in our test, not the product
pkillreturns once SIGTERM is delivered, not once the process is gone. The testwaits zero milliseconds for the old agent to exit, so if its teardown outlives the two
docker execround-trips that follow,pslists both pids and the assertion reports arestart that did happen as one that did not.
The upgrade the test is actually verifying completed correctly — the run's own output
shows the other two assertions (
Connected, new version) were never reached onlybecause this one failed first.
Evidence (throwaway Linode VM,
main@37a003d)Reproduction environment built by following
.github/workflows/runner-integration-cli-tests.ymlstep for step: PMM Server
perconalab/pmm-server:3-dev-latest, digestsha256:c431a6e1a488c965c3bed3c56c8a9a882fbd125b64f68269409bc08fbd078821— byte-identicalto the image the failing run recorded to Launchable — the same
latest-tarballclient, andthe same
--database pdpgsql=16 --database ps,ENCRYPTED_CLIENT_CONFIG=truesetup.The flake itself did not reproduce: PMM-T2227 passed 5/5 at
main. What the box didshow is why the shape of the CI output can only be this race:
pkill(SIGTERM → gone)pmm-serverpaused)pkillreturning →psrunningSo the margin here is ~6–15×, which is why an idle 6-CPU VM never trips it; CI evidently
did, at ~450 ms of unaccounted teardown.
Two controls pin down which race it is, and rule out "pmm-agent ignored SIGTERM":
agent-local JSON server (
agent/agentlocal/agent_local.go:339) and dies. Verifieddirectly on the box.
kill -STOPon the old agent beforepkill(so it can never process the signal)reproduces that instead:
psshows only the old pid, because the replacement diedon the port.
kill -CONTthen lets it handle the queued SIGTERM and exit.For CI to have seen both
170and351alive,170must therefore have alreadyreleased its listeners and been mid-exit — a shutdown in progress, not a hang. That is
exactly what a zero-wait assertion catches, and it is not a product defect: nothing
promises
pkillmakes a process vanish synchronously.Fix
Poll until the old pid is out of
psbefore starting the replacement. Bounded at 30s andfailing loudly (
Old pmm-agent process is still running after SIGTERM!) if it never exits,so a genuine "pmm-agent ignores SIGTERM" regression still surfaces rather than being
waited away. It also removes the second, nastier failure mode above, where the replacement
agent starts into an occupied port and dies.
Verification
On the same VM, on this branch:
--grep "@generic|@unregister": 43 passed, 13 skipped, 1 failed. The onefailure is PMM-T1219, exit code
127fromunzip pmm-summary.zip—unzipis notinstalled on the repro VM; it is present on the GitHub runner and that test passed in
the failing CI run. Unrelated to this change.
npx tsc --noEmit: no errors fromgeneric.spec.ts(only pre-existingtsconfig.jsonTS 7.0 deprecation warnings).
Because the flake never reproduced, this change is verified by mechanism rather than by a
red-to-green flip: the assertion it removes had no timing margin by construction. Only the
next scheduled runs can confirm the flake is gone from CI.
Generated by Claude Code