Commit c73bbfb
authored
fix(e2e/discovery): Capture fixture service diagnostics on failure (#54205)
### What does this PR do?
Makes `dumpDebugInfo` in the discovery E2E suite produce usable output again.
It queried `/discovery/debug`, which was removed in fd2b24d ("discovery: remove old discovery check", #39417). Every failure since has logged a 404 body instead of any discovery state — `Not found` in `system-probe-lite` mode (system-probe-lite's `NOTFOUND` constant) and `404 page not found` in `system-probe` mode (Go's `ServeMux` default). Both strings are visible in every failure of the two jobs behind DSCVR-621.
Replaced with endpoints that still exist, plus the information needed to tell *"discovery did not report the service"* apart from *"the fixture service was not running"* — a distinction the previous output could not make at all:
- `GET /discovery/state` — which implementation is live.
- `POST /discovery/services` for the fixture services' PIDs. This is the only endpoint that reports what discovery actually sees. It is caller-driven, so it must be told which PIDs to inspect, and it is POST-only with a JSON body in `system-probe-lite`.
- `ps` `ELAPSED` per fixture PID. Discovery never asks about a process younger than `discovery.service_collection_min_process_age` (1 minute by default), so a value below that explains a missing service on its own, and one that keeps resetting across dumps means the service is crash-looping rather than booting slowly.
- `systemctl status` and `journalctl` per fixture service. The journal is the only place a fixture's own output ends up.
- `ss -ltnp`. Discovery only reports a process once it has a listening socket.
PIDs come from each unit's cgroup rather than its main PID, because the process the tests match on is not always the main one: `node-json-server` runs through npm, which spawns the `node` process that serves the port.
### Motivation
DSCVR-621. Investigating that flake, the suite's own diagnostics contributed nothing: `/discovery/debug` returned a 404 body in all four failing subtests of both jobs, and nothing recorded the fixture services' state, so it was impossible to tell from CI output whether discovery had failed to report a running service or the service had never started. Determining that required reconstructing process lifetimes from `workload-list` dumps.
In the two failures behind the ticket the fixture service was in fact not running — `ruby3.0` appears in only one of four `workload-list` dumps of job 1874204604, created 9s before the dump was taken. `journalctl` would have said why in one line.
### Describe how you validated your changes
Since a green CI run does not exercise any of this — `dumpDebugInfo` only runs after a failure, and I confirmed the passing `new-e2e-discovery` job contains none of the new log markers — the endpoints and commands were verified directly.
**Endpoints**, against a `system-probe-lite` built from this tree and driven with the exact command strings this PR sends:
| Request | Response |
|---|---|
| `GET /discovery/state` | `{"implementation":"system-probe-lite"}` |
| `POST /discovery/services`, `{"new_pids":[…]}` + `Content-Type` | `{"services":[{"pid":…,"generated_name":…}],…}` |
| `GET /discovery/debug` (the call being removed) | `Not found` — the exact string seen in every DSCVR-621 failure |
| `POST /discovery/services` with no `Content-Type` | `Bad request` |
| `POST` with a misspelled field | `{"services":[],…}` — unknown fields ignored silently |
| malformed JSON | `Bad request` |
The misspelled-field row is why the field name is called out in a comment: an empty result is indistinguishable from "matched no services", and `core.Params` cannot be imported here because it belongs to the main module, which `test/new-e2e` does not depend on.
**Commands and their exit codes**, on Ubuntu 22.04 / systemd 249 / cgroup v2, matching the image the tests run on: `ps` for an exited PID exits 1 and `curl` to a missing socket exits 7, so both are routed through a helper that keeps the output and drops the status — otherwise a crash-looping fixture (a PID that dies between the cgroup read and `ps`) would have replaced the real failure with an error about the diagnostic. Also confirmed there that `ps`'s header is `ELAPSED`, comma-separated PID lists work, a missing `cgroup.procs` is handled, and `ss -ltn` prints `0.0.0.0:<port>` followed by padding.
Additionally:
- `dda inv linter.go --targets=./test/new-e2e/tests/discovery` — clean.
- `new-e2e-discovery` passes on this branch.
- `ss` is already used against these images elsewhere in the E2E suite (`test/new-e2e/tests/agent-metric-pipelines/common/adp.go`, `test/new-e2e/tests/agent-platform/common/bound-port/unix.go`).
- No assertions are added or changed — this only affects what is logged when a test has already failed.
Not verified: the `system.slice/<svc>.service/cgroup.procs` path against the actual fixture units. The cgroup v2 layout was checked on a matching host, but not with these unit names.
### Additional Notes
Diagnostics only, deliberately: this does not attempt to fix the flake. #54206 builds on this one and addresses the cause.
Co-authored-by: vincent.whitchurch <vincent.whitchurch@datadoghq.com>1 parent 2271844 commit c73bbfb
1 file changed
Lines changed: 83 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
172 | 194 | | |
173 | 195 | | |
174 | 196 | | |
175 | 197 | | |
176 | | - | |
177 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
178 | 232 | | |
179 | | - | |
180 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
181 | 246 | | |
182 | | - | |
183 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
184 | 261 | | |
185 | 262 | | |
186 | 263 | | |
| |||
0 commit comments