mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-31 04:53:01 +02:00
yangerd: Fix containers
This commit is contained in:
@@ -362,12 +362,20 @@ func (c *ContainerCollector) container(ctx context.Context, ps map[string]interf
|
||||
"status": asString(ps["Status"]),
|
||||
}
|
||||
|
||||
cmd := strings.Join(asStringSlice(ps["Command"]), " ")
|
||||
if cmd != "" {
|
||||
out["command"] = cmd
|
||||
inspect := c.podmanInspect(ctx, name)
|
||||
|
||||
// Report the actual running command line as the config-false
|
||||
// "cmdline" leaf (an unrestricted string), built from inspect's
|
||||
// Path + Args like the legacy yanger collector. Do NOT report it
|
||||
// into the config-true "command" leaf: that leaf has a restrictive
|
||||
// pattern and a real command line (e.g. one containing "&&" or
|
||||
// quotes) fails YANG validation, which rejects the entire
|
||||
// containers subtree on read.
|
||||
if path := asString(inspect["Path"]); path != "" {
|
||||
parts := append([]string{path}, asStringSlice(inspect["Args"])...)
|
||||
out["cmdline"] = strings.Join(parts, " ")
|
||||
}
|
||||
|
||||
inspect := c.podmanInspect(ctx, name)
|
||||
if net := c.network(ps, inspect); len(net) > 0 {
|
||||
out["network"] = net
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestContainerBasicInfo(t *testing.T) {
|
||||
"Ports": []
|
||||
}
|
||||
]`),
|
||||
"podman inspect web": []byte(`[{}]`),
|
||||
"podman inspect web": []byte(`[{"Path":"nginx","Args":["-g","daemon off;"]}]`),
|
||||
"podman stats --no-stream --format json --no-reset web": []byte(`[]`),
|
||||
},
|
||||
Errors: map[string]error{},
|
||||
@@ -87,8 +87,8 @@ func TestContainerBasicInfo(t *testing.T) {
|
||||
if c["status"] != "Up 2 hours" {
|
||||
t.Fatalf("status mismatch: %v", c["status"])
|
||||
}
|
||||
if c["command"] != "nginx -g daemon off;" {
|
||||
t.Fatalf("command mismatch: %v", c["command"])
|
||||
if c["cmdline"] != "nginx -g daemon off;" {
|
||||
t.Fatalf("cmdline mismatch: %v", c["cmdline"])
|
||||
}
|
||||
if c["running"] != true {
|
||||
t.Fatalf("running expected true, got %v", c["running"])
|
||||
|
||||
Reference in New Issue
Block a user