Browse code

Merge pull request #28885 from vdemeester/revert-service-ps-all

Revert "Add -a option to service/node ps"

Alexander Morozov authored on 2016/12/01 05:02:34
Showing 6 changed files
... ...
@@ -17,7 +17,6 @@ import (
17 17
 
18 18
 type psOptions struct {
19 19
 	nodeIDs   []string
20
-	all       bool
21 20
 	noResolve bool
22 21
 	noTrunc   bool
23 22
 	filter    opts.FilterOpt
... ...
@@ -44,7 +43,6 @@ func newPsCommand(dockerCli *command.DockerCli) *cobra.Command {
44 44
 	flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output")
45 45
 	flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names")
46 46
 	flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided")
47
-	flags.BoolVarP(&opts.all, "all", "a", false, "Show all tasks (default shows tasks that are or will be running)")
48 47
 
49 48
 	return cmd
50 49
 }
... ...
@@ -74,11 +72,6 @@ func runPs(dockerCli *command.DockerCli, opts psOptions) error {
74 74
 		filter := opts.filter.Value()
75 75
 		filter.Add("node", node.ID)
76 76
 
77
-		if !opts.all && !filter.Include("desired-state") {
78
-			filter.Add("desired-state", string(swarm.TaskStateRunning))
79
-			filter.Add("desired-state", string(swarm.TaskStateAccepted))
80
-		}
81
-
82 77
 		nodeTasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter})
83 78
 		if err != nil {
84 79
 			errs = append(errs, err.Error())
... ...
@@ -2,7 +2,6 @@ package service
2 2
 
3 3
 import (
4 4
 	"github.com/docker/docker/api/types"
5
-	"github.com/docker/docker/api/types/swarm"
6 5
 	"github.com/docker/docker/cli"
7 6
 	"github.com/docker/docker/cli/command"
8 7
 	"github.com/docker/docker/cli/command/idresolver"
... ...
@@ -15,7 +14,6 @@ import (
15 15
 
16 16
 type psOptions struct {
17 17
 	serviceID string
18
-	all       bool
19 18
 	quiet     bool
20 19
 	noResolve bool
21 20
 	noTrunc   bool
... ...
@@ -39,7 +37,6 @@ func newPsCommand(dockerCli *command.DockerCli) *cobra.Command {
39 39
 	flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output")
40 40
 	flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names")
41 41
 	flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided")
42
-	flags.BoolVarP(&opts.all, "all", "a", false, "Show all tasks (default shows tasks that are or will be running)")
43 42
 
44 43
 	return cmd
45 44
 }
... ...
@@ -67,11 +64,6 @@ func runPS(dockerCli *command.DockerCli, opts psOptions) error {
67 67
 		}
68 68
 	}
69 69
 
70
-	if !opts.all && !filter.Include("desired-state") {
71
-		filter.Add("desired-state", string(swarm.TaskStateRunning))
72
-		filter.Add("desired-state", string(swarm.TaskStateAccepted))
73
-	}
74
-
75 70
 	tasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter})
76 71
 	if err != nil {
77 72
 		return err
... ...
@@ -2638,7 +2638,7 @@ _docker_service_ps() {
2638 2638
 
2639 2639
 	case "$cur" in
2640 2640
 		-*)
2641
-			COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) )
2641
+			COMPREPLY=( $( compgen -W "--filter -f --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) )
2642 2642
 			;;
2643 2643
 		*)
2644 2644
 			local counter=$(__docker_pos_first_nonflag '--filter|-f')
... ...
@@ -22,7 +22,7 @@ Usage:  docker node ps [OPTIONS] [NODE...]
22 22
 List tasks running on one or more nodes, defaults to current node.
23 23
 
24 24
 Options:
25
-  -a, --all            Show all tasks (default shows tasks that are or will be running)
25
+  -a, --all            Display all instances
26 26
   -f, --filter value   Filter output based on conditions provided
27 27
       --help           Print usage
28 28
       --no-resolve     Do not map IDs to Names
... ...
@@ -22,7 +22,6 @@ Usage:  docker service ps [OPTIONS] SERVICE
22 22
 List the tasks of a service
23 23
 
24 24
 Options:
25
-  -a, --all             Show all tasks (default shows tasks that are or will be running)
26 25
   -f, --filter filter   Filter output based on conditions provided
27 26
       --help            Print usage
28 27
       --no-resolve      Do not map IDs to Names
... ...
@@ -226,88 +226,6 @@ func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *check.C) {
226 226
 	c.Assert(out, checker.Not(checker.Contains), name+".1")
227 227
 	c.Assert(out, checker.Not(checker.Contains), name+".2")
228 228
 	c.Assert(out, checker.Not(checker.Contains), name+".3")
229
-
230
-	out, err = d.Cmd("node", "ps", "--filter", "desired-state=running", "self")
231
-	c.Assert(err, checker.IsNil)
232
-	c.Assert(out, checker.Contains, name+".1")
233
-	c.Assert(out, checker.Contains, name+".2")
234
-	c.Assert(out, checker.Contains, name+".3")
235
-
236
-	out, err = d.Cmd("node", "ps", "--filter", "desired-state=shutdown", "self")
237
-	c.Assert(err, checker.IsNil)
238
-	c.Assert(out, checker.Not(checker.Contains), name+".1")
239
-	c.Assert(out, checker.Not(checker.Contains), name+".2")
240
-	c.Assert(out, checker.Not(checker.Contains), name+".3")
241
-}
242
-
243
-func (s *DockerSwarmSuite) TestSwarmServiceTaskListAll(c *check.C) {
244
-	d := s.AddDaemon(c, true, true)
245
-
246
-	name := "service-task-list-1"
247
-	out, err := d.Cmd("service", "create", "--name", name, "--replicas=3", "busybox", "top")
248
-	c.Assert(err, checker.IsNil)
249
-	c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
250
-
251
-	// make sure task has been deployed.
252
-	waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 3)
253
-
254
-	out, err = d.Cmd("service", "ps", name)
255
-	c.Assert(err, checker.IsNil)
256
-	c.Assert(out, checker.Contains, name+".1")
257
-	c.Assert(out, checker.Contains, name+".2")
258
-	c.Assert(out, checker.Contains, name+".3")
259
-
260
-	// Get the last container id so we can restart it to cause a task error in the history
261
-	containerID, err := d.Cmd("ps", "-q", "-l")
262
-	c.Assert(err, checker.IsNil)
263
-
264
-	_, err = d.Cmd("stop", strings.TrimSpace(containerID))
265
-	c.Assert(err, checker.IsNil)
266
-
267
-	waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 3)
268
-
269
-	out, err = d.Cmd("service", "ps", name)
270
-	c.Assert(err, checker.IsNil)
271
-	c.Assert(out, checker.Count, name, 3)
272
-
273
-	out, err = d.Cmd("service", "ps", name, "-a")
274
-	c.Assert(err, checker.IsNil)
275
-	c.Assert(out, checker.Count, name, 4)
276
-}
277
-
278
-func (s *DockerSwarmSuite) TestSwarmNodeTaskListAll(c *check.C) {
279
-	d := s.AddDaemon(c, true, true)
280
-
281
-	name := "node-task-list"
282
-	out, err := d.Cmd("service", "create", "--name", name, "--replicas=3", "busybox", "top")
283
-	c.Assert(err, checker.IsNil)
284
-	c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
285
-
286
-	// make sure task has been deployed.
287
-	waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 3)
288
-
289
-	out, err = d.Cmd("service", "ps", name)
290
-	c.Assert(err, checker.IsNil)
291
-	c.Assert(out, checker.Contains, name+".1")
292
-	c.Assert(out, checker.Contains, name+".2")
293
-	c.Assert(out, checker.Contains, name+".3")
294
-
295
-	// Get the last container id so we can restart it to cause a task error in the history
296
-	containerID, err := d.Cmd("ps", "-q", "-l")
297
-	c.Assert(err, checker.IsNil)
298
-
299
-	_, err = d.Cmd("stop", strings.TrimSpace(containerID))
300
-	c.Assert(err, checker.IsNil)
301
-
302
-	waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 3)
303
-
304
-	out, err = d.Cmd("node", "ps", "self")
305
-	c.Assert(err, checker.IsNil)
306
-	c.Assert(out, checker.Count, name, 3)
307
-
308
-	out, err = d.Cmd("node", "ps", "self", "-a")
309
-	c.Assert(err, checker.IsNil)
310
-	c.Assert(out, checker.Count, name, 4)
311 229
 }
312 230
 
313 231
 // Test case for #25375