gates / gates (push) Successful in 32s
A count above 0 in a running container's current run fires the existing app_oom line (source cgroup/docker in the details), whatever Docker's OOMKilled says. Old agent: 404 back-off; no agent: Docker's flag only. Tests TestR528_* red first / red-proved. Commit only.
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package agentapi
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// GuestOOMKillsState mirrors the agent's GET /guest/oom-kills (R-528, agent ≥ the R-528 commit): the kernel's oom_kill
|
|
// counter of each of THIS guest's containers, read on the host — Docker's own OOMKilled flag can stay false inside an
|
|
// LXC guest. Containers maps the full 64-hex container id to the count for the container's current run.
|
|
// Available=false: the guest has no cgroup folder the host can read. An agent that predates the route answers 404 (a
|
|
// *StatusError) — the controller then keeps Docker's flag only.
|
|
type GuestOOMKillsState struct {
|
|
VMID int `json:"vmid"`
|
|
Available bool `json:"available"`
|
|
Containers map[string]int64 `json:"containers"`
|
|
}
|
|
|
|
// GuestOOMKills calls GET /guest/oom-kills.
|
|
func (c *Client) GuestOOMKills(ctx context.Context) (GuestOOMKillsState, error) {
|
|
var out GuestOOMKillsState
|
|
body, err := c.get(ctx, "/guest/oom-kills")
|
|
if err != nil {
|
|
return out, err
|
|
}
|
|
if err := json.Unmarshal(body, &out); err != nil {
|
|
return out, fmt.Errorf("agentapi: decode /guest/oom-kills: %w", err)
|
|
}
|
|
return out, nil
|
|
}
|