support show numbers of global service in service ls command#27710
Conversation
65c9aea to
de687d7
Compare
|
I think |
|
Oh, to be honest, your example is better. @AkihiroSuda |
|
@allencloud SGTM |
|
It will add a new column for the output maybe need more discussion. WDYT? @thaJeztah @AkihiroSuda @vdemeester |
|
/cc @thaJeztah @aluzzardi @stevvooe any reason why we did not add |
|
I agree with having a separate column as well (#27670 (comment)) 😄 |
cli/command/service/list.go
Outdated
There was a problem hiding this comment.
Is the "total" here always using the total node count? If so, that should probably be changed to take constraints into account (which is supported for global services)
There was a problem hiding this comment.
No, actually it is not the total node count. Here is scene:
- 5 nodes, 2 managers, 3 workers.
- docker service create --constraint node.role==manager ubuntu:14.04 sleep 100000
- before 1.13.0, global service will be every node even if the node does not meet the constraint. While since PR Only create global service tasks on nodes that satisfy the constraints swarmkit#1570, task will only be on nodes which satisfies the constraints. However this PR counts all tasks of a global service, and I think it will be OK for docker version both before 1.13- and 1.13+
There was a problem hiding this comment.
Since 1.13.0, task of global service will only on node which satisfies constraints. So this PR counts node which only has the corresponding task. PTAL @thaJeztah
1d94a47 to
5c69224
Compare
|
Added a column already. PTAL @AkihiroSuda @vdemeester @thaJeztah |
|
design LGTM, but ping @aluzzardi PTAL |
|
LGTM /cc @dongluochen |
cli/command/service/list.go
Outdated
There was a problem hiding this comment.
can we avoid 2D map because we are just interested in the number of tasks?
There was a problem hiding this comment.
Yeah, what we are interested in is number of tasks in every Service. I think we should classify tasks via different service.
If you have any better ways to implement this, please feel free to tell me.
There was a problem hiding this comment.
You can implement the same thing with a struct-keyed map but I don't see this being accessed by taskID, so I don't quite understand what is being attempted here.
This should be called tasksByService or taskCountByService?
|
ping @dongluochen . PTAL, thanks. 😃 |
1c1fc64 to
d166eb8
Compare
cli/command/service/list.go
Outdated
There was a problem hiding this comment.
Why is the map by task ID necessary? Does TaskList return duplicate tasks?
There was a problem hiding this comment.
Oh, Yes, It is unnecessary now. Thanks a lot for your review. PTAL
036671a to
6b2d8d0
Compare
There was a problem hiding this comment.
Extra whitespace here. @thaJeztah does this matter in markdown?
There was a problem hiding this comment.
Don't think it's a problem here, but @allencloud would be nice to clean up 😄
There was a problem hiding this comment.
done, Thanks. Now cleaned up this. 😄
|
LGTM |
6b2d8d0 to
5021c03
Compare
|
LGTM |
5021c03 to
5a6c967
Compare
Signed-off-by: allencloud <allen.sun@daocloud.io>
5a6c967 to
ea03f09
Compare
|
Solve conflict because merging of #28029 |
mdlinville
left a comment
There was a problem hiding this comment.
LGTM. Leaving the merge for @thaJeztah
|
oops, late to the party, thanks! |
|
LGTM |
…vice-in-service-ls support show numbers of global service in service ls command
fixes #27670
make command
docker service lsshow numbers for global services, like :if a sevice's mode is global, actually we can not get the total number of task in this service. Here what I did is that we collect all the tasks, and classify via task.ServiceID. Then we can know that in a service how many tasks are in this service. In addition, we can not simply get the number of nodes to make it the total number of tasks in a service, since user can use constraints in creating global service, then task number in a service may not equal to the number of nodes.
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
Signed-off-by: allencloud allen.sun@daocloud.io