Commit Graph

215 Commits

Author SHA1 Message Date
0411944839 Merge pull request #31856 from jim-minter/more_races
Resolve a set of race conditions in logging and attaching code
Upstream-commit: 5eca7f7c5d7678f6548cd7d90199d67ce98d4c98
Component: engine
2017-04-26 16:04:02 -07:00
740b35daa9 Prevent ContainerLogs from hanging if container doesn't run for long
Signed-off-by: Jim Minter <jminter@redhat.com>
Upstream-commit: 4fdb17c77765fb44ae263d5012bb79bb8bd15456
Component: engine
2017-04-20 12:27:51 +01:00
62eff90f69 Add logdrivers to /info
This is required for swarmkit to be able to filter based on log driver.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 17abacb8946ed89496fcbf07a0288fafe24cb7b0
Component: engine
2017-04-11 18:07:15 -04:00
276ea6a456 Implement plugins for logging drivers
Logging plugins use the same HTTP interface as other plugins for basic
command operations meanwhile actual logging operations are handled (on
Unix) via a fifo.

The plugin interface looks like so:

```go
type loggingPlugin interface {
  StartLogging(fifoPath string, loggingContext Context) error
  StopLogging(fifoPath)
```

This means a plugin must implement `LoggingDriver.StartLogging` and
`LoggingDriver.StopLogging` endpoints and be able to consume the passed
in fifo.

Logs are sent via stream encoder to the fifo encoded with protobuf.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 27bd6842f8518780b99fdb42f8e7f84c17856d87
Component: engine
2017-04-10 13:17:20 -04:00
334f054f13 refactor logs and support service logs /w tty
Refactor container logs system to make communicating log messages
internally much simpler. Move responsibility for marshalling log
messages into the REST server. Support TTY logs. Pave the way for fixing
the ambiguous bytestream format. Pave the way for fixing details.

Signed-off-by: Drew Erny <drew.erny@docker.com>
Upstream-commit: 1044093bb0aa12eb8972361a93b9bc8c4ddd857b
Component: engine
2017-04-06 17:54:11 -07:00
3f185ca5af Merge pull request #27565 from rothrock/env-by-regex
[splunk] Use a regex to match environment variables
Upstream-commit: 1325f667eeb42b717c2f9d369f2ee6d701a280e3
Component: engine
2017-03-31 10:46:48 -04:00
47709fd338 Merge pull request #31083 from xulike666/fight-for-readability
fix some typos from module contrib to man
Upstream-commit: 57fd478169071b09f0e6657cc1c2568d80c1bed3
Component: engine
2017-03-03 15:13:01 +01:00
458406a7f3 Merge pull request #31212 from fate-grand-order/fixed
use t.Fatal() to output the err message and fix typo
Upstream-commit: a6576b8a2bff0feeb67918403caa3df0c4c37673
Component: engine
2017-02-27 12:26:35 +09:00
9632b0f1e8 use t.Fatal() to output the err message where the values used for formatting
text does not appear to contain a placeholder

Signed-off-by: Helen Xie <chenjg@harmonycloud.cn>
Upstream-commit: 2a8d6368d4a930203b93f75914173ab65bf3b0bc
Component: engine
2017-02-23 10:16:22 +08:00
4fcd45b6de Merge pull request #31263 from nalind/journal-doublefree
Synchronize the cursor returned by followJournal
Upstream-commit: b3e7f7013719be7d11d513335ff55802eaf543ce
Component: engine
2017-02-22 17:45:49 -08:00
53075c0a1f Synchronize the cursor returned by followJournal
Make sure that the cursor value returned by followJournal() is the last
of the values returned by its goroutine's calls to drainJournal() by
waiting for it, rather than returning a value that may be superceded by
another if we're singalling the goroutine that it should exit by closing
a pipe.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Upstream-commit: d57c330617efb97cad736a3e4ede82bb46ebbbf2
Component: engine
2017-02-22 16:22:00 -05:00
73607300a9 Prevent freeing a possible invalid pointer from journald
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Upstream-commit: 81630df85439adab1836e83a7e645d67b1c0eb83
Component: engine
2017-02-22 07:54:10 -08:00
cdf7829892 fix some typos from module contrib to man
Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
Upstream-commit: e0577d5fe876ec92de21c808c31e97e052654223
Component: engine
2017-02-18 10:08:55 +08:00
ee71506629 Fix cpu spin waiting for log write events
This loop is not ever going to return since it's never actually setting
the `err` var except on the first iteration.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 7a179972ff963706404f91671960b144dec98d65
Component: engine
2017-02-15 21:41:32 -05:00
6b54bc16cf Merge pull request #30694 from godefroi/26937-fix-rfc5424-log-format-1
Add NILVALUE for STRUCTURED-DATA in RFC5424 logs
Upstream-commit: 14790e4008c030626eeb8886c4578441af561cf0
Component: engine
2017-02-07 23:22:39 +01:00
3b9f4a63b1 Merge pull request #30136 from tg123/master
Windows: return err instead of panic when convert string to utf16
Upstream-commit: d38753303a60181acbf15c8e01a223f2013439c8
Component: engine
2017-02-06 14:00:00 -08:00
79e327614e Add NILVALUE for STRUCTURED-DATA in RFC5424 logs
RFC 5424 (https://tools.ietf.org/html/rfc5424#section-6.2) requires that
STRUCTURED-DATA be present, either as NILVALUE (-) or as one or more
SD-ELEMENT items. Because Docker doesn't ever create any SD-ELEMENT items,
the format should output the NILVALUE instead. This resolves parsing issues
in various RFC 5424-compliant syslog servers.

Signed-off-by: Mark Parker <godefroi@gmail.com>
Upstream-commit: b7d802bbccdf7ec6e4cc1ead733663cdce9768c0
Component: engine
2017-02-02 15:16:14 -07:00
c238856aa4 Use sync.Pool for logger Messages
This reduces allocs and bytes used per log entry significantly as well
as some improvement to time per log operation.

Each log driver, however, must put messages back in the pool once they
are finished with the message.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 3f4fccb65f0ef286c9c4e0f01c4ae7bb09a6ad89
Component: engine
2017-02-01 13:52:37 -05:00
11a6f80b8b Implement optional ring buffer for container logs
This allows the user to set a logging mode to "blocking" (default), or
"non-blocking", which uses the ring buffer as a proxy to the real log
driver.

This allows a container to never be blocked on stdio at the cost of
dropping log messages.

Introduces 2 new log-opts that works for all drivers, `log-mode` and
`log-size`. `log-mode` takes a  value of "blocking", or "non-blocking"
I chose not to implement this as a bool since it is difficult to
determine if the mode was set to false vs just not set... especially
difficult when merging the default daemon config with the container config.
`log-size` takes a size string, e.g. `2MB`, which sets the max size
of the ring buffer. When the max size is reached, it will start
dropping log messages.

```
BenchmarkRingLoggerThroughputNoReceiver-8           	2000000000	        36.2 ns/op	 856.35 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputWithReceiverDelay0-8   	300000000	       156 ns/op	 198.48 MB/s	      32 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay1-8        	2000000000	        36.1 ns/op	 857.80 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay10-8       	1000000000	        36.2 ns/op	 856.53 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay50-8       	2000000000	        34.7 ns/op	 894.65 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay100-8      	2000000000	        35.1 ns/op	 883.91 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay300-8      	1000000000	        35.9 ns/op	 863.90 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay500-8      	2000000000	        35.8 ns/op	 866.88 MB/s	       0 B/op	       0 allocs/op
```

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 054abff3b67bb5d66323e5418a43c845a3eac8a1
Component: engine
2017-02-01 13:52:37 -05:00
21f88f4070 Merge pull request #29863 from ncdc/journald-logdriver-drain-one-more-time-after-follow-ends
journald logs: drain 1 more time at container exit
Upstream-commit: dc78b3a1d4376ffa4417e465f9a816eaf8c8fbb5
Component: engine
2017-02-01 10:30:14 -08:00
733876ff1e Support of CreateLogGroup for awslogs
This fix tries to address the issue raised in 29344 where it was
not possible to create log group for awslogs (CloudWatch) on-demand.
Log group has to be created explicitly before container is running.

This behavior is inconsistent with AWS logs agent where log groups
are always created as needed.

There were several concerns previously (See comments in 19617 and 29344):
1. There is a limit of 500 log groups/account/region so resource might
be exhausted if there is any typo or incorrect region.
2. Logs are generated for every container so CreateLogGroup (or equally,
DescribeLogGroups) might be called every time, which is redundant and
potentially surprising.
3. CreateLogStream and CreateLogGroup have different IAM policies.

This fix addresses the issue by add `--log-opt awslogs-create-group`
which by default is `false`. It requires user to explicitly request
that log groups be created as needed.

Related unit test has been updated. And tests have also been done
manually in AWS.

This fix fixes 29334.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 864b0c2e47e66e1037115b5d7267e641ba776d49
Component: engine
2017-01-27 11:15:17 -08:00
7c251eb224 journald logs: drain 1 more time at container exit
In the journald log driver, attempt to drain the journal 1 more time
after being told to stop following the log. Due to a possible race
condition, sometimes data is written to the journal at almost the same
time the log watch is closed, and depending on the order of operations,
sometimes you miss the last journal entry.

Signed-off-by: Andy Goldstein <agoldste@redhat.com>
Upstream-commit: 76f58d7294259bd9bbc91082077d32bbbcb9fd9a
Component: engine
2017-01-25 09:29:21 -05:00
310ff23136 Use a regex to match environment variables #27565
Signed-off-by: Joseph Rothrock <rothrock@rothrock.org>
Upstream-commit: 9758a2a72445eb767ea81b44a73aabb5a8005bab
Component: engine
2017-01-19 15:30:11 -08:00
f5282be2f9 Close logwatcher on context cancellation
This commit addresses 2 issues:

  1. in `tailfile()` if somehow the `logWatcher.Msg` were to become full and the watcher closed before space was made into it, we were getting stuck there forever since we were not checking for the watcher getting closed
  2. when servicing `docker logs`, if the command was cancelled we were not closing the watcher (and hence notifying it to stop copying data)

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Upstream-commit: fb2bb3653e2755d971f21debfecbd7c878a3c23f
Component: engine
2017-01-17 14:36:13 -08:00
6d2604c368 return err instead of panic when convert string to utf16
Signed-off-by: Boshi Lian <farmer1992@gmail.com>
Upstream-commit: 1c770c6d8c531bf237252eb23e183cad26b7f64a
Component: engine
2017-01-14 02:21:22 +08:00
c880e6de34 fix syscall.GUID composite literal uses unkeyed fields
Signed-off-by: yupengzte <yu.peng36@zte.com.cn>
Upstream-commit: 230b7c2e4c3a33731580a1613b47c183c6ee06e6
Component: engine
2017-01-03 17:12:15 +08:00
d18def1e2d Merge pull request #28852 from miaoyq/rename-log-context
Rename 'context' to 'loginfo' in the logger module
Upstream-commit: a33105626870bfcbca97052b25b114e005a145ac
Component: engine
2016-12-30 01:13:49 +01:00
cabd6a6108 Rename 'context' to 'loginfo' in the logger module
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

gofmt

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

remove 'api/types/container/config.go' from this PR

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

change 'LogInfo' to 'Info'

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Upstream-commit: 17ec911da7d4b77b069d9f6c8c010865e19acc6c
Component: engine
2016-12-29 19:13:44 +08:00
e8ed8e5184 gcplogs: forcibly set HOME on static UNIX binary
Fix #29344

If HOME is not set, the gcplogs logging driver will call os/user.Current() via oauth2/google.
However, in static binary, os/user.Current() leads to segfault due to a glibc issue that won't be fixed
in a short term. (golang/go#13470, https://sourceware.org/bugzilla/show_bug.cgi?id=19341)
So we forcibly set HOME so as to avoid call to os/user/Current().

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Upstream-commit: b86e3bee5aea8e72b7f08e104ebb5d6cb18f8890
Component: engine
2016-12-29 03:17:26 +00:00
1b913d2b2c Merge pull request #29475 from AkihiroSuda/vendor-oauth2-3
Vendor gcplogs deps
Upstream-commit: b0aab6e83e9d0235fef99b16a45fd2680995168f
Component: engine
2016-12-28 11:55:03 -05:00
433a6ae35a Merge pull request #29314 from vdemeester/no-more-utils
Remove the utils package
Upstream-commit: b9ee31ae027bbd62477fea3f58023c90f051db00
Component: engine
2016-12-22 15:21:05 +01:00
e43da16101 remove client-side for supported logging drivers
The `docker logs` command performed a
client-side check if the container's
logging driver was supported.

Now that we allow the client to connect
to both "older" and "newer" daemon versions,
this check is best done daemon-side.

This patch remove the check on the client
side, and leaves validation to the daemon,
which should be the source of truth.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 05dc9846e1266e6a3629c26851acb633a380dd17
Component: engine
2016-12-19 14:30:01 +01:00
729e9d0578 vendor: google.golang.org/cloud -> cloud.google.com/go
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Upstream-commit: ff2f8755741a3c5bdd29bab9c36985c6d05d531a
Component: engine
2016-12-16 08:36:18 +00:00
62b7ace712 daemon: return directly without ifs where possible
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
Upstream-commit: 3a42518042b36ad90950a3abf0aa125c0342b2c4
Component: engine
2016-12-14 22:36:58 +02:00
57d5fc9bfa Move templates to pkg/templates
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 04f7a03359ac009ad2cd548fa93124a66e880ae5
Component: engine
2016-12-12 09:34:03 +01:00
bb58024492 Merge pull request #28797 from miaoyq/fix-a-err-of-logger
Fix a error of the function 'CopyMessage' in 'daemon/logger/logger.go'
Upstream-commit: 6151ad19ad2a5cd2ec2c3afc08ed07f64623ae36
Component: engine
2016-11-30 13:27:40 -08:00
2f9e7efdc3 Merge pull request #28829 from lixiaobing10051267/masterDaemon
check typos and fix in daemon directory
Upstream-commit: 022c13271b274074a6190952f1888b01c13c4a7c
Component: engine
2016-11-26 14:33:09 +01:00
115737bff2 check typos and fix in daemon directory
Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>

Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>
Upstream-commit: cf4f5b47710b3875767f997fc2eb3386cb0b66c0
Component: engine
2016-11-26 17:23:21 +08:00
c3ca7189dc Fix a error of the function 'CopyMessage' in 'daemon/logger/logger.go'
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

add a test for 'CopyMessage'

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Upstream-commit: 3b82eac65fc365a89f64ccaba98f8f3b5c9c5787
Component: engine
2016-11-24 20:08:54 +08:00
475c963e9d Optimize the function 'Context.Name()' and replace 'Context.ContainerName' that need to remove slash with 'Context.Name()'.
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Upstream-commit: 52fd6e46645de098d803bfc510c4c24af1099def
Component: engine
2016-11-24 09:24:29 +08:00
4d1ac89cc0 Swap usage of LazyDLL and LoadDLL to LazySystemDLL.
Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: 22c83c567f379dfd475ecd35665e1cc9e5b9c314
Component: engine
2016-11-22 14:57:11 -08:00
166b57151d function TestCreateSuccess uses a wrong variable LogGroupName
Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>
Upstream-commit: 320c93824b7c4dca3086258264ab142fe4530165
Component: engine
2016-11-16 16:48:36 +08:00
a40c9e3002 Merge pull request #26088 from akirakoyasu/patch-fluent-unixsocket
Proposal: unix-sockets support in Fluentd logging driver
Upstream-commit: 806f09bf32c49cd0493a97522cd809b09b52dfb6
Component: engine
2016-11-09 12:49:06 +01:00
00b0b30b49 Clean up journald logger
We clean up the journald logger with these four changes.

1. Make field array static
2. Make function name more appropriate
3. Initialize the file descriptors only once
4. Avoid copying the journald cursor

Point 4 is the most significant change: instead of treating the journald
cursor like a Go string we use it as a raw C.char pointer. That way we
avoid the copying by the C.CString and C.GoString functions.

Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Upstream-commit: d359daaa487e68d187cc30c9da8fc08a158c7f79
Component: engine
2016-11-08 19:09:59 +01:00
930e01c1dd Merge pull request #28035 from thaJeztah/add-test-for-long-loglines
add tests for long log-lines and trailing lines
Upstream-commit: 9f7cc7d0320b93236169a7e0f6f9d69fa8c91bb8
Component: engine
2016-11-04 07:59:20 +01:00
7379675f65 Merge pull request #27912 from LK4D4/vndr
project: use vndr for vendoring
Upstream-commit: c07234707878412eaaeab252af19adac8cf25d6b
Component: engine
2016-11-03 18:30:19 -07:00
61646d77af project: use vndr for vendoring
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: f2614f2107c838d014d31b806e3b8a9f1395cb2b
Component: engine
2016-11-03 15:31:46 -07:00
069eefcf38 Updated AWS logstream to understand tags
Signed-off-by: French Ben <frenchben@docker.com>
Upstream-commit: 3661510f7f9f389f25a6d6a065509ae224372994
Component: engine
2016-11-03 13:49:40 -07:00
f08ca94e09 add tests for long log-lines and trailing lines
this adds new tests to test logging of long log-lines
(without newlines), and trailing log-lines.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: ee34dd9f8a8a0246dae94385ed2ca56691085842
Component: engine
2016-11-03 10:01:00 -07:00
a99c149057 Fixes #21803 : Removing unused configuration in daemon/logger/fluentd
Signed-off-by: milindchawre <milindchawre@gmail.com>
Upstream-commit: 3463bbcc710ce56a8d2ace1e2a2aaaf22db3a516
Component: engine
2016-11-02 11:11:02 +00:00