Support ps subcommand on podcvd#2814
Conversation
|
Sharing an explanation of this PR I did during dev/test of Lenzon - Hope you find it helpful. |
3984bd6 to
830944e
Compare
|
@dxapd Could I get the review for the modification on |
| return rowMap | ||
| } | ||
|
|
||
| func parsePsOutput(stdout, ipAddr string) ([]map[string]string, []psColumn, error) { |
There was a problem hiding this comment.
Is re-string parsing the human-readable output of cvd ps back into a data structure the best way to do this? The purpose of cvd ps is to grab all of the groups' information from instance_manager_ and convert it into human-readable output based on kHeaders. This seems to add a redundant step, when you could:
- call
cvd fleetand use standard JSON parsing to put it into a data structure, and then usekHeadersto format your output, - or possibly call into instance_manager_ yourself (not sure if this one is possible from podcvd).
But before that, do podcvd commands need to be formatted a specific way? If not, you may be able to just directly feed the output of cvd ps into stdout.
There was a problem hiding this comment.
But before that, do podcvd commands need to be formatted a specific way? If not, you may be able to just directly feed the output of cvd ps into stdout.
The only requirement is podcvd ps should have same format as cvd ps. When multiple Cuttlefish instance groups exist, each group is in separated container instances. When executing cvd ps from containers, podcvd ps needs to parse the data in advance, and then reconstruct it.
Leaving a representative example why not parsing the human-readable output can be problematic, difference on the padding.
$ podman exec -it <container_name_for_cvd_1> cvd ps
GROUPS NAMES ID STATUS CREATED ADB_SERIAL WEB_ACCESS
cvd_1 1 1 Running 2026-07-13 01:16:15 192.168.112.1:6520 https://192.168.112.1:11443/devices/cvd_1-1-1/files/client.html
$ podman exec -it <container_name_for_cvd_11> cvd ps
GROUPS NAMES ID STATUS CREATED ADB_SERIAL WEB_ACCESS
cvd_11 1 1 Running 2026-07-13 01:16:27 192.168.112.11:6520 https://192.168.112.11:11443/devices/cvd_2-1-1/files/client.html
There was a problem hiding this comment.
Also I should have considered potential format changes in the future. In case of having long-running Cuttlefish instance group via podcvd, its container instance has older version of cvd and there can have another running container instance with newer version of cvd perhpas. Even for such case, podcvd ps should provide information as possible as cvd ps does.
From podcvd modification, you could see any header row(e.g. GROUPS NAMES ID ...) isn't hardcoded there.
Suggested output format of
cvd ps:Suggested output format of
podcvd ps:Context: b/530777084