Open danielboydston opened 1 year ago
Thanks for reporting! I gave this a quick try, and was able to reproduce this. Had a (brief) glance and the CLI code, and nothing immediately stood out as incorrect on the CLI side :thinking_face:
The command defaults to use self
for filtering tasks (i.e., show tasks running on the manager node you're connected to), but that gets replaced if one or more nodes are passed as argument;
https://github.com/docker/cli/blob/a0756c3c2cacebf5e5dc6454cc280c3ddf675176/cli/command/node/ps.go#L36-L40
After which it collect tasks for each node (getting the tasklist for each node (filtering the tasks based on node-ID)); https://github.com/docker/cli/blob/a0756c3c2cacebf5e5dc6454cc280c3ddf675176/cli/command/node/ps.go#L65-L88
Some possibilities;
self
by default" (and the logic duplicated?)My reproducing was on docker 23.0.2;
docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
yg550ettvsjn6g6t840iaiwgb * swarm-test-01 Ready Active Reachable 23.0.2
2lm9w9kbepgvkzkkeyku40e65 swarm-test-02 Ready Active Leader 23.0.2
hc0pu7ntc7s4uvj4pv7z7pz15 swarm-test-03 Ready Active Reachable 23.0.2
n41b2cijmhifxxvz56vwrs12q swarm-test-04 Ready Active 23.0.2
docker node ps
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
hyrvvroi2ve0 service.1 thajeztah/redacted:latest swarm-test-01 Running Running 5 days ago
n0k48214ocjx \_ service.1 thajeztah/redacted:latest swarm-test-01 Shutdown Failed 5 days ago "task: non-zero exit (2)"
t4aoc5bom8lj jvs.2 thajeztah/redacted2 swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
v5d1wdx5hguk \_ jvs.2 thajeztah/redacted2 swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
wawc9957rrc2 \_ jvs.2 thajeztah/redacted2 swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
root@swarm-test-01:~# docker node ps swarm-test-01 swarm-test-02
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
hyrvvroi2ve0 \_ service.1 thajeztah/redacted:latest swarm-test-01 Running Running 5 days ago
hyrvvroi2ve0 \_ service.1 thajeztah/redacted:latest swarm-test-01 Running Running 5 days ago
n0k48214ocjx \_ service.1 thajeztah/redacted:latest swarm-test-01 Shutdown Failed 5 days ago "task: non-zero exit (2)"
n0k48214ocjx \_ service.1 thajeztah/redacted:latest swarm-test-01 Shutdown Failed 5 days ago "task: non-zero exit (2)"
t4aoc5bom8lj \_ jvs.2 thajeztah/redacted2:latest swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
t4aoc5bom8lj \_ jvs.2 thajeztah/redacted2:latest swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
v5d1wdx5hguk \_ jvs.2 thajeztah/redacted2:latest swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
v5d1wdx5hguk \_ jvs.2 thajeztah/redacted2:latest swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
wawc9957rrc2 \_ jvs.2 thajeztah/redacted2:latest swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
wawc9957rrc2 \_ jvs.2 thajeztah/redacted2:latest swarm-test-01 Shutdown Rejected 2 months ago "No such image: thajeztah/reda…"
pd8ofvb3qy4q jvs.4 thajeztah/redacted2:latest swarm-test-02 Running Running 3 weeks ago
jbszl4zfhoih \_ jvs.4 thajeztah/redacted2:latest swarm-test-02 Shutdown Complete 3 weeks ago
ocj5hoan9wbz \_ jvs.4 thajeztah/redacted2:latest swarm-test-02 Shutdown Failed 6 months ago "No such container: jvs.4.ocj5…"
xpg5cyy30g8i \_ jvs.4 thajeztah/redacted2:latest swarm-test-02 Shutdown Complete 6 months ago
24.0.6 still has this problem [ where can I vote for this issue :-) ]
Can I pick up this issue? I have started contributing to open-source projects, and this issue seems to be a good one to start with.
I also have a hunch that the problem is with how the filter is built in the for loop!
https://github.com/docker/cli/blob/ddd4c399305bb4fc9a290a2cd321b55df11280a6/cli/command/node/ps.go#L77-L78
When running the docker node ps
command with multiple nodes in the for loop, the filter state retains node-specific data from previous iterations, causing task entries to be duplicated for the first specified node. This occurs because the filter object, being a dictionary type, was reused and modified across iterations, accumulating previous node filters.
I will set up the project, and see if this is the problem!
Can I pick up this issue?
Sure, go for it! I don't think anyone has had time to work on this, so go ahead 🤘
@thaJeztah I created this PR
Description
When executing 'docker node ps node1 node2', containers running on node1 will appear in the list twice, while containers for node2 will appear only once.
Switching the order of the nodes 'docker node ps node2 node1' results in the containers on node2 being listed twice.
Running the command when specifying only one node correctly displays each container only once.
Reproduce
Expected behavior
Output should be a list of all containers running in the swarm with a single entry for each container.
docker version
docker info
Additional Info
No response