Commit Graph

1170 Commits

Author SHA1 Message Date
ff72d92410 Add builtin nodes discovery
Use `pkg/discovery` to provide nodes discovery between daemon instances.

The functionality is driven by two different command-line flags: the
experimental `--cluster-store` (previously `--kv-store`) and
`--cluster-advertise`. It can be used in two ways by interested
components:

1. Externally by calling the `/info` API and examining the cluster store
   field. The `pkg/discovery` package can then be used to hit the same
   endpoint and watch for appearing or disappearing nodes. That is the
   method that will for example be used by Swarm.
2. Internally by using the `Daemon.discoveryWatcher` instance. That is
   the method that will for example be used by libnetwork.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Upstream-commit: 7d193ef1f3b5fcd6aa55b7376116e2617be12e06
Component: engine
2015-09-25 14:52:09 -07:00
b31922f0fe Merge pull request #16567 from calavera/context_per_request
Define a context per request.
Upstream-commit: ff92f45be49146cd7ac7716c36d89de989cb262e
Component: engine
2015-09-25 13:01:51 -07:00
556d0a0826 refactor create to not expose internal data structures
- use existing exposed type

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
Upstream-commit: 93bd57b0b21e1a802b80388c8fc034780e3200fc
Component: engine
2015-09-25 09:35:18 -07:00
8cec2a263a Define a context per request.
Avoid creating a global context object that will be used while the daemon is running.

Not only this object won't ever be garbage collected, but it won't ever be used for anything else than creating other contexts in each request. I think it's a bad practive to have something like this sprawling aroud the code.

This change removes that global object and initializes a context in the cases we don't have already one, like shutting down the server.
This also removes a bunch of context arguments from functions that did nothing with it.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 27c76522dea91ec585f0b5f0ae1fec8c255b7b22
Component: engine
2015-09-24 18:44:53 -04:00
a273d038b8 Merge pull request #16228 from duglin/ContextualizeEvents
Add context.RequestID to event stream
Upstream-commit: de4164043546d2b9ee3bf323dbc41f4979c84480
Component: engine
2015-09-24 14:16:22 -07:00
bf44c732da Add context.RequestID to event stream
This PR adds a "request ID" to each event generated, the 'docker events'
stream now looks like this:

```
2015-09-10T15:02:50.000000000-07:00 [reqid: c01e3534ddca] de7c5d4ca927253cf4e978ee9c4545161e406e9b5a14617efb52c658b249174a: (from ubuntu) create
```
Note the `[reqID: c01e3534ddca]` part, that's new.

Each HTTP request will generate its own unique ID. So, if you do a
`docker build` you'll see a series of events all with the same reqID.
This allow for log processing tools to determine which events are all related
to the same http request.

I didn't propigate the context to all possible funcs in the daemon,
I decided to just do the ones that needed it in order to get the reqID
into the events. I'd like to have people review this direction first, and
if we're ok with it then I'll make sure we're consistent about when
we pass around the context - IOW, make sure that all funcs at the same level
have a context passed in even if they don't call the log funcs - this will
ensure we're consistent w/o passing it around for all calls unnecessarily.

ping @icecrime @calavera @crosbymichael

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: 26b1064967d9fcefd4c35f60e96bf6d7c9a3b5f8
Component: engine
2015-09-24 11:56:37 -07:00
88a3d0ed92 client/search: small logic fix
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
Upstream-commit: 19613feddf0043756a42a1766abde33a47c346dc
Component: engine
2015-09-24 11:11:03 +08:00
8316b128fe Merge pull request #16411 from duglin/DaemonErrors
Move more 'daemon' errors to the new error package
Upstream-commit: ebe7ef9fc2238f008101f31c0c405cbc460ab757
Component: engine
2015-09-23 21:20:56 -04:00
4422b77499 Merge pull request #16415 from HuKeping/dockerinfo
Format output of docker info
Upstream-commit: 40e856041265d6030768286f1b228f042c0f768b
Component: engine
2015-09-23 21:15:23 -04:00
1547f964d2 Merge pull request #16497 from MHBauer/attach-refactor-new
refactor attach to not use internal data structures
Upstream-commit: ddd0c47412dd30f1d333b5bd53e22c9949d1e86f
Component: engine
2015-09-23 16:52:39 -07:00
9890a83a8f Merge pull request #16484 from HuKeping/history-format
Format the output of docker history
Upstream-commit: d71ae4577293e6600447433126f4034d80d85ddb
Component: engine
2015-09-23 16:52:21 -07:00
4429613429 Merge pull request #16289 from cpuguy83/11957_fix_stdin_block_after_container_exit
Ensure stdin does not block after container stop
Upstream-commit: c0c941627a2a516ce540aac2d9e3d579baa3efde
Component: engine
2015-09-23 15:29:48 -07:00
5ee0f81315 Move more 'daemon' errors to the new error package
Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: 0a734182eb09497806a9ff3e1c8031ab1ab39f13
Component: engine
2015-09-23 09:51:45 -07:00
65ae094a39 refactor attach to not use internal data structures
- refactor to make it easier to split the api in the future

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
Upstream-commit: 8aef1a33eb730a7c9b7e92b688bc63e6a3c69f62
Component: engine
2015-09-23 08:55:21 -07:00
75633de557 Format output of docker info
Format those info which will only be displayed when daemon is
in debug mode.

Signed-off-by: Hu Keping <hukeping@huawei.com>
Upstream-commit: 141e91c4803124bdf55dd45a06998748b0ef5fb2
Component: engine
2015-09-23 14:35:13 +08:00
6f56efa779 Merge pull request #16331 from calavera/server_middlewares
Organize server pre-func logic in middlewares.
Upstream-commit: 9dc0973655bba2250b906bc8b316d87af809a15e
Component: engine
2015-09-22 16:10:42 -05:00
a5107b7eb0 Format the output of docker history
Once there have '\t' in the "CREATED BY" section, it will possibly
cause a messy output of docker history.

Signed-off-by: Hu Keping <hukeping@huawei.com>
Upstream-commit: 6353f3a7b58fe7ef1cb33660003c1d7205f2e6c0
Component: engine
2015-09-22 21:27:20 +08:00
f5dba44987 Merge pull request #15864 from dmcgowan/notary-offline
Support content trust offline
Upstream-commit: a7e23cab8d10003914e39f1c954278c7be6bd759
Component: engine
2015-09-21 21:11:36 -07:00
a91e1506bf Merge pull request #16419 from HuKeping/comments
Comment: add description for some code which hard to understand
Upstream-commit: f97e6f2a374b85c5ef14b19b805991d98a7f3d27
Component: engine
2015-09-21 20:44:54 -07:00
fc5d97018d Comment: add description for some code which hard to understand
Signed-off-by: Hu Keping <hukeping@huawei.com>
Upstream-commit: 3b443abec254cb8214881e11af4c09e923cd2dd1
Component: engine
2015-09-22 09:34:49 +08:00
f1430df5ab Merge pull request #16404 from duglin/FixRenameError
Fix 'rename' error msg and error checking
Upstream-commit: 0c71c192395e259d76a51e08c7c3bd73eb6f16e7
Component: engine
2015-09-21 15:51:02 -04:00
7a04c92cc8 Merge pull request #16437 from runcom/invalid-logger-address
daemon: logger: error out on daemon start if invalid logger address
Upstream-commit: d572bab4a09eb7d60961867d2d2f9896595a3271
Component: engine
2015-09-21 14:53:47 -04:00
651f1e747f Organize server pre-func logic in middlewares.
It defines global middlewares for every request.
This makes the server slightly more composable.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 0fea04d27ee91d7b57e0a77b110db1c861768c74
Component: engine
2015-09-21 14:27:06 -04:00
8e71940329 add docker server version to /info
Signed-off-by: Zhang Kun <zkazure@gmail.com>
Upstream-commit: 7cf343d1064e3d8211597c67574ff4ddff316fa1
Component: engine
2015-09-21 21:15:32 +08:00
7020653250 api: server: container: fix wrong comment
This comment was wrongly referring to the old job mechanism and it
wasn't clear what it was trying to document.

Signed-off-by: Antonio Murdaca <runcom@linux.com>
Upstream-commit: 76b3b5431475709b27f0c113f9319321388a49d1
Component: engine
2015-09-21 00:46:16 +02:00
4168ba7ed4 docker restarts running OR stopped containers, docs edit rm "running"
Signed-off-by: Sally O'Malley <somalley@redhat.com>
Upstream-commit: e41753678d5ffd6c505f1984943bc36d34e134bb
Component: engine
2015-09-20 09:16:27 -04:00
3a09d2b95a Fix 'rename' error msg and error checking
`docker rename foo ''` would result in:
```
usage: docker rename OLD_NAME NEW_NAME
```
which is the old engine's way of return errors - yes that's in the
daemon code.  So I fixed that error msg to just be normal.

While doing that I noticed that using an empty string for the
source container name failed but didn't print any error message at all.
This is because we would generate a URL like: ../containers//rename/..
which would cause a 301 redirect to ../containers/rename/..
however the CLI code doesn't actually deal with 301's - it just ignores
them and returns back to the CLI code/caller.

Rather than changing the CLI to deal with 3xx error codes, which would
probably be a good thing to do in a follow-on PR, for this immediate
issue I just added a cli-side check for empty strings for both old and
new names. This way we catch it even before we hit the daemon.

API callers will get a 404, assuming they follow the 301, for the
case of the src being empty, and the new error msg when the destination
is empty - so we should be good now.

Add tests for both cases too.

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: 848792c42e61070adc4107a39d6a044e2ed615f7
Component: engine
2015-09-18 11:12:22 -07:00
3194323cdb Ensure stdin does not block after container stop
Fixes #11957
Fixes #12319

Also removes check for Darwin when the stdin reader is closed as it
doesn't appear to block any more.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 3dbfb3d38c4dcfb602e12ed2828d22d155897518
Component: engine
2015-09-18 13:48:07 -04:00
a5c36fcdf5 Merge pull request #16389 from HuKeping/stats-zero
Reset data of stats in docker cli when container stopped
Upstream-commit: 41646cb4e318b025a5a5c627481e551c49f726e2
Component: engine
2015-09-18 18:59:51 +02:00
5be2b08002 Reset data of stats in docker cli when container stopped
When use `docker stats` to minitor a running container and then stop it,
there are some fields need to be reset to zero. Otherwise it will keep
displaying the data it received last time.

Signed-off-by: Hu Keping <hukeping@huawei.com>
Upstream-commit: da67833e63f317d8f20ffed5c3250f442900bdae
Component: engine
2015-09-18 15:24:13 +08:00
3904dd3167 Move api/errors/ to errors/
Per @calavera's suggestion: https://github.com/docker/docker/pull/16355#issuecomment-141139220

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: a283a30fb026aad4434a9f2e34f7ce955d27a957
Component: engine
2015-09-17 11:54:14 -07:00
2d5e18cda2 Merge pull request #16355 from duglin/DaemonErrors
Convert some "daemon" static error strings to the new errocode package format
Upstream-commit: 828e4ac45a5b4954997949570b9b032c57137849
Component: engine
2015-09-17 11:48:37 -07:00
d13159ba93 Merge pull request #16361 from MHBauer/stats-refactor
refactor stats to not use internal data structures
Upstream-commit: cafee2eb4544442cd1307c1484235261b5b2752a
Component: engine
2015-09-17 08:28:07 -07:00
b0bf51095d Merge pull request #16336 from mountkin/fix-hijack
error should be checked earlier in the hijack function
Upstream-commit: ffaee8fe78a5e7203b28895788e2aa16b4315b21
Component: engine
2015-09-17 09:38:48 +02:00
b23ea59e6d refactor stats to not use internal data structures
- refactor to make it easier to split the api in the future
 - addition to check the existing test case and make sure it contains
   some expected output

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
Upstream-commit: 2d5d606fd368814ead4ff189eeae264f2af8691b
Component: engine
2015-09-16 17:28:52 -07:00
6295202aba Convert some "daemon" static error strings to the new errocode package format
Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: f7d4b4fe2b130a522dee847a657218806180fa52
Component: engine
2015-09-16 16:16:42 -07:00
5e58ae50d3 Merge pull request #15786 from HuKeping/stats-network
Refactor the statistics of network in docker stats
Upstream-commit: 259a0fb16ceac921763172127183059dea7e3c46
Component: engine
2015-09-16 20:29:16 +02:00
267460c20b error should be checked earlier in the hijack function
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Upstream-commit: f2d978ccf9ae29aa8ac06791ac0ffeceb4167d9b
Component: engine
2015-09-16 20:28:07 +08:00
ded3de600a Support for passing build-time variables in build context
- The build-time variables are passed as environment-context for command(s)
run as part of the RUN primitve. These variables are not persisted in environment of
intermediate and final images when passed as context for RUN. The build environment
is prepended to the intermediate continer's command string for aiding cache lookups.
It also helps with build traceability. But this also makes the feature less secure from
point of view of passing build time secrets.

- The build-time variables also get used to expand the symbols used in certain
Dockerfile primitves like ADD, COPY, USER etc, without an explicit prior definiton using a
ENV primitive. These variables get persisted in the intermediate and final images
whenever they are expanded.

- The build-time variables are only expanded or passed to the RUN primtive if they
are defined in Dockerfile using the ARG primitive or belong to list of built-in variables.
HTTP_PROXY, HTTPS_PROXY, http_proxy, https_proxy, FTP_PROXY and NO_PROXY are built-in
variables that needn't be explicitly defined in Dockerfile to use this feature.

Signed-off-by: Madhav Puri <madhav.puri@gmail.com>
Upstream-commit: 54240f8da9992880e20a1508e9a6f0e59f2adef1
Component: engine
2015-09-16 03:31:15 -07:00
700bfcfe4a Merge pull request #15069 from duglin/UseErrorPackage
Use the new error package
Upstream-commit: e91f2c26ce38787e159162d2c4a43744396e3308
Component: engine
2015-09-15 09:28:53 -04:00
c71aa53e3d Refactor the statistics of network in docker stats
For now docker stats will sum the rxbytes, txbytes, etc. of all
the interfaces.

It is OK for the output of CLI `docker stats` but not good for
the API response, especially when the container is in sereval
subnets.

It's better to leave these origianl data to user.

Signed-off-by: Hu Keping <hukeping@huawei.com>
Upstream-commit: d3379946ec96fb6163cb8c4517d7d5a067045801
Component: engine
2015-09-15 15:40:34 +08:00
1f4f6c3414 Merge pull request #15931 from vdemeester/api-client-ps-coverage
Add more unit tests on api/client/ps package
Upstream-commit: 7ce270d4ea17d5ec01fe00581fbabf4c5274f0e1
Component: engine
2015-09-14 14:02:49 -07:00
bb8ff26c08 Use the new error package
This is the first step in converting out static strings into well-defined
error types.  This shows just a few examples of it to get a feel for how things
will look. Once we agree on the basic outline we can then work on converting
the rest of the code over.

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: 628b9a41b09fde3ce1493f7d4f1495b9afaa506c
Component: engine
2015-09-14 13:11:01 -07:00
0dc44a70e4 Ignore ping errors in notary repository setup
Notary is capable of acting in offline mode, making use of cache TUF data.
When ping is not successful, notary should still be attempted without error.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 5e11cd43aa21a9d0eb1f5f205f05dc7b14ee4d43
Component: engine
2015-09-14 11:08:25 -07:00
862065b3b2 Add log reading to the journald log driver
If a logdriver doesn't register a callback function to validate log
options, it won't be usable.  Fix the journald driver by adding a dummy
validator.

Teach the client and the daemon's "logs" logic that the server can also
supply "logs" data via the "journald" driver.  Update documentation and
tests that depend on error messages.

Add support for reading log data from the systemd journal to the
journald log driver.  The internal logic uses a goroutine to scan the
journal for matching entries after any specified cutoff time, formats
the messages from those entries as JSONLog messages, and stuffs the
results down a pipe whose reading end we hand back to the caller.

If we are missing any of the 'linux', 'cgo', or 'journald' build tags,
however, we don't implement a reader, so the 'logs' endpoint will still
return an error.

Make the necessary changes to the build setup to ensure that support for
reading container logs from the systemd journal is built.

Rename the Jmap member of the journald logdriver's struct to "vars" to
make it non-public, and to make it easier to tell that it's just there
to hold additional variable values that we want journald to record along
with log data that we're sending to it.

In the client, don't assume that we know which logdrivers the server
implements, and remove the check that looks at the server.  It's
redundant because the server already knows, and the check also makes
using older clients with newer servers (which may have new logdrivers in
them) unnecessarily hard.

When we try to "logs" and have to report that the container's logdriver
doesn't support reading, send the error message through the
might-be-a-multiplexer so that clients which are expecting multiplexed
data will be able to properly display the error, instead of tripping
over the data and printing a less helpful "Unrecognized input header"
error.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
Upstream-commit: e611a189cb3147cd79ccabfe8ba61ae3e3e28459
Component: engine
2015-09-11 16:50:03 -04:00
c3a694b001 Merge pull request #16215 from HuKeping/save
Refactor CLI docker save
Upstream-commit: bc48194ded4892d277345e45defee66a24f36399
Component: engine
2015-09-11 13:52:59 -04:00
b7b1e671cd Refactor CLI docker save
Signed-off-by: Hu Keping <hukeping@huawei.com>
Upstream-commit: 22be1e443fa49bafd6aa3ab6c1eb0595fd9fb2b1
Component: engine
2015-09-11 15:31:55 +08:00
d563cc164c Signal to stop a container.
Allow to set the signal to stop a container in `docker run`:
- Use `--stop-signal` with docker-run to set the default signal the container will use to exit.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 0e50d946a25beb134bce2aaf4a209b5cfcbacf8f
Component: engine
2015-09-10 19:56:05 -04:00
9f56a7069d Added tags list to /images/:id/json api.
It closes #10139.

Signed-off-by: Rozhnov Alexandr <nox73@ya.ru>
Upstream-commit: e9e68fa2d29a5e3053fb876b19b5ac5bc6d1c222
Component: engine
2015-09-10 11:55:01 +03:00
da795b0534 Merge pull request #15953 from duglin/DaemonContext
Add a "context" to the api/server/* code
Upstream-commit: 6efe45990d7d50940b8c070be7b45b7a7399d327
Component: engine
2015-09-09 17:28:38 -07:00