From 1d3f7cc012c7491cae69d8939ce91bcd4d950403 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Thu, 4 Jun 2015 19:47:46 -0700 Subject: [PATCH] Default events since to current time Signed-off-by: Brian Goff (cherry picked from commit 74c12aa42918e3f349afcb46e6e54b724ef789a9) --- api/server/server.go | 4 ++++ docs/man/docker-events.1.md | 5 +++++ docs/sources/reference/commandline/cli.md | 3 +++ integration-cli/docker_cli_events_test.go | 7 +++++++ 4 files changed, 19 insertions(+) diff --git a/api/server/server.go b/api/server/server.go index 638eb197a..bb3a09ebe 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -398,6 +398,7 @@ func (s *Server) getEvents(version version.Version, w http.ResponseWriter, r *ht } until = u } + timer := time.NewTimer(0) timer.Stop() if until > 0 { @@ -456,6 +457,9 @@ func (s *Server) getEvents(version version.Version, w http.ResponseWriter, r *ht } current, l := es.Subscribe() + if since == -1 { + current = nil + } defer es.Evict(l) for _, ev := range current { if ev.Time < since { diff --git a/docs/man/docker-events.1.md b/docs/man/docker-events.1.md index bff04a6d1..b0723c623 100644 --- a/docs/man/docker-events.1.md +++ b/docs/man/docker-events.1.md @@ -63,7 +63,12 @@ Again the output container IDs have been shortened for the purposes of this docu 2015-01-28T20:25:45.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) die 2015-01-28T20:25:46.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) stop + +If you do not provide the --since option, the command returns only new and/or +live events. + # HISTORY April 2014, Originally compiled by William Henry (whenry at redhat dot com) based on docker.com source material and internal work. June 2014, updated by Sven Dowideit +June 2015, updated by Brian Goff diff --git a/docs/sources/reference/commandline/cli.md b/docs/sources/reference/commandline/cli.md index a731979d9..439ca57e5 100644 --- a/docs/sources/reference/commandline/cli.md +++ b/docs/sources/reference/commandline/cli.md @@ -1115,6 +1115,9 @@ and Docker images will report: untag, delete +If you do not provide the --since option, the command +returns only new and/or live events. + #### Filtering The filtering flag (`-f` or `--filter`) format is of "key=value". If you would like to use diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index d6518ce8d..02767c29a 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -563,3 +563,10 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) { // ignore, done } } + +// #13753 +func (s *DockerSuite) TestEventsDefaultEmpty(c *check.C) { + dockerCmd(c, "run", "-d", "busybox") + out, _ := dockerCmd(c, "events", fmt.Sprintf("--until=%d", daemonTime(c).Unix())) + c.Assert(strings.TrimSpace(out), check.Equals, "") +}