Skip to content

Commit 59028c4

Browse files
committed
Fix #1466: 'show container' shows no output
A container's command line, as reported by podman, may comtain environment variables, which the current regexp (added in ed4fe58) does not support. Extend the regexp to allow environment variables and add an operational, config false, 'cmdline' leaf node to allow any characters to be reported for the full command line in the operational output. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent 2603b0e commit 59028c4

6 files changed

Lines changed: 33 additions & 6 deletions

File tree

src/confd/yang/confd/infix-containers.yang

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ module infix-containers {
2222
prefix infix-sys;
2323
}
2424

25+
revision 2026-04-20 {
26+
description "Add cmdline operational leaf showing the full process command line
27+
(entrypoint + args) from 'podman inspect'. Allow environment variable
28+
references (dollar sign, braces) in the command override.";
29+
reference "internal";
30+
}
31+
2532
revision 2026-02-23 {
2633
description "Input validation improvements";
2734
reference "internal";
@@ -257,10 +264,19 @@ module infix-containers {
257264
leaf command {
258265
description "Override ENTRYPOINT from image and run command + args.";
259266
type string {
260-
pattern '[a-zA-Z0-9_./ :=@%^,+-]+';
267+
pattern '[a-zA-Z0-9_./ :=@%^,${}()+-]+';
261268
}
262269
}
263270

271+
leaf cmdline {
272+
description "Full process command line currently executing in the container,
273+
combining the entrypoint and its arguments as reported by
274+
'podman inspect'. May differ from the configured 'command'
275+
override when the image provides its own entrypoint wrapper.";
276+
config false;
277+
type string;
278+
}
279+
264280
leaf hostname {
265281
description "Sets the container host name, available inside the container.
266282
File renamed without changes.

src/confd/yang/containers.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- sh -*-
22
MODULES=(
33
"infix-interfaces -e containers"
4-
"infix-containers@2026-02-23.yang"
4+
"infix-containers@2026-04-20.yang"
55
)

src/statd/python/yanger/infix_containers.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,21 @@ def container(ps):
223223
"status": ps["Status"]
224224
}
225225

226-
# Bonus information, may not be available
227-
if ps["Command"]:
228-
out["command"] = " ".join(ps["Command"])
229-
230226
inspect = podman_inspect(out["name"])
231227
if inspect and isinstance(inspect, list) and len(inspect) > 0:
232228
inspect = inspect[0]
233229
else:
234230
inspect = {}
235231

232+
path = inspect.get("Path", "")
233+
args = inspect.get("Args", [])
234+
if path:
235+
out["cmdline"] = " ".join([path] + args)
236+
237+
cmd = inspect.get("Config", {}).get("Cmd", [])
238+
if cmd:
239+
out["command"] = " ".join(cmd)
240+
236241
net = network(ps, inspect)
237242
if net:
238243
out["network"] = net

test/case/statd/containers/infix-containers.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"image-id": "d6930d60a73be9980f8e19b4b4f63586a6d3492178e20bea962e4e9b8c654033",
99
"running": true,
1010
"status": "Up About a minute",
11+
"cmdline": "/usr/bin/tini -- /usr/sbin/httpd -f -v",
1112
"command": "/usr/sbin/httpd -f -v",
1213
"network": {
1314
"interface": [
@@ -28,6 +29,7 @@
2829
"image-id": "d6930d60a73be9980f8e19b4b4f63586a6d3492178e20bea962e4e9b8c654033",
2930
"running": true,
3031
"status": "Up About a minute",
32+
"cmdline": "/usr/bin/tini -- /usr/sbin/httpd -f -v -p 91",
3133
"command": "/usr/sbin/httpd -f -v -p 91",
3234
"network": {
3335
"interface": [
@@ -50,6 +52,7 @@
5052
"image-id": "7a3cc502436250357a6664100a600f306334b4d7203890b85b7ea9b8da6b5665",
5153
"running": true,
5254
"status": "Up About a minute",
55+
"cmdline": "/usr/bin/tini -- /usr/sbin/nft-helper /etc/nftables.conf",
5356
"command": "/usr/sbin/nft-helper /etc/nftables.conf",
5457
"network": {
5558
"host": true

test/case/statd/containers/operational.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@
11871187
"infix-containers:containers": {
11881188
"container": [
11891189
{
1190+
"cmdline": "/usr/bin/tini -- /usr/sbin/httpd -f -v",
11901191
"command": "/usr/sbin/httpd -f -v",
11911192
"id": "78d28082c2e5d494c82aa181c95118ce498e25930ad9e288ba010257ca336378",
11921193
"image": "localhost/curios-httpd-oci-amd64-v24.11.0:latest",
@@ -1207,6 +1208,7 @@
12071208
"status": "Up About a minute"
12081209
},
12091210
{
1211+
"cmdline": "/usr/bin/tini -- /usr/sbin/httpd -f -v -p 91",
12101212
"command": "/usr/sbin/httpd -f -v -p 91",
12111213
"id": "3451cfceca4eee1091c1dfedece2faee99bc8a729e781799d9c0b4368a31d86d",
12121214
"image": "localhost/curios-httpd-oci-amd64-v24.11.0:latest",
@@ -1229,6 +1231,7 @@
12291231
"status": "Up About a minute"
12301232
},
12311233
{
1234+
"cmdline": "/usr/bin/tini -- /usr/sbin/nft-helper /etc/nftables.conf",
12321235
"command": "/usr/sbin/nft-helper /etc/nftables.conf",
12331236
"id": "4e7c3daeba15546e7640014b9ee46e389737ed36583e5cb2f8b75a07a82e8523",
12341237
"image": "localhost/curios-nftables-oci-amd64-v24.11.0:latest",

0 commit comments

Comments
 (0)