Commit Graph

78 Commits

Author SHA1 Message Date
Michael Crosby ae9af437f0 After parsing flags check that the command is nsenter
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-07 10:48:29 -07:00
Michael Crosby 5226b39d15 Fix issues in nsenter.c and console handling
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-06 22:04:28 -07:00
Michael Crosby a48b001013 Refactor execin code to be simpler
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-06 18:44:41 -07:00
Michael Crosby 390f413a92 Make syncpipe transport generic data
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-06 18:00:52 -07:00
Michael Crosby 8b6c0b7ec6 Add linux style formatting
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-05 16:04:18 -07:00
Michael Crosby f3b0a3a0e6 Move nsenter C code to separate file
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-05 16:04:08 -07:00
Vishnu Kannan f90eee10ef Remove debug message.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-05 22:13:23 +00:00
Vishnu Kannan 74b99b8dd6 Check for "nsenter" in args before parsing flags. Addressed comments.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-05 22:13:23 +00:00
Vishnu Kannan e5e40b6ef0 Docker 'runin' demands passing flags before 'nsenter' cli option.
Docker does not require RunIn API. Hence that API has been removed.
nsinit CLI has been modified to work around the nsenter changes.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-05 22:13:23 +00:00
Mrunal Patel 7f3bbbb47b Move locking to caller.
Docker-DCO-1.1-Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)
2014-08-01 19:06:56 -04:00
Bernerd Schaefer 041fafc763 DefaultCreateCommand supports command w/ flags
namespaces.DefaultCreateCommand prepends the user-supplied command to
execute with "--", so that "nsinit init" does not attempt to interpret
it.

Docker-DCO-1.1-Signed-off-by: Bernerd Schaefer <bj.schaefer@gmail.com> (github: bernerdschaefer)
2014-07-31 21:32:10 +02:00
Tianon Gravi e31771fa42 Move "pkg/user" into libcontainer and add support for GetUserGroupSupplementary to return "Home" too
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
2014-07-29 10:59:18 -06:00
Victor Marmol 7dc9dc3473 Merge pull request #58 from maebashi/fix-setns-order
fix the order of setns()
2014-07-29 09:45:13 -07:00
maebashi f333c5ce9b remove unnecessary headers
Docker-DCO-1.1-Signed-off-by: Takahiro Maebashi <maebashi@iij.ad.jp> (github: maebashi)
2014-07-28 11:02:35 +09:00
Aleksa Sarai 01a7f19afe namespaces: nsenter: ignore nonexistent namespaces
If a particular kernel doesn't have namespace directories that
libcontainer tries to attain during nsenter(), ignore the error (this is
consistent with the previous implementation of nsenter()).

Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
2014-07-28 11:02:17 +09:00
Michael Crosby 52e7350c9d Correct nsenter fprintf syntax
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-24 14:54:05 -07:00
Michael Crosby 4568ca76c8 Update imports for new docker location
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-24 14:28:49 -07:00
Vishnu Kannan 1f2828770d Updated RunIn API to match the new console handling behavior in HEAD.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-07-22 19:49:59 +00:00
Vishnu Kannan 145299f9d8 Adding RunIn to run a user specified command in an existing container, wait for it to exit and return the exit code.
RunIn will connect to a user specified Terminal before running the command.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-07-22 19:49:59 +00:00
Michael Crosby 0dcae82acb Initially mount /sys as ro instead of remount
The issue with doing a remount as ro with sysfs is that if a container
is still in one of the hosts namepsaces, commonly with the NET
namespace, the remount will cause the host's systems sysfs to be
remounted as ro also.  We can fix this correctly by not doing the
remount and just mount sys as ro in the first place.

The other remounts are individual files within proc so they will not
have this issue.

For context please see:
https://github.com/dotcloud/docker/issues/7101
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-18 14:13:38 -07:00
Michael Crosby b56aa0658a Don't open slave in parent
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-15 18:24:15 -07:00
Michael Crosby d661720fd7 Remove terminal handling in libcontainer
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-15 16:55:11 -07:00
Michael Crosby e9ec77ab34 Migrate selinux system xattr calls and prctl calls
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-14 16:55:49 -07:00
Michael Crosby a2dc64cf30 Add initial system pkg to libcontainer
Port over console and ptmx code into console package
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-14 16:46:51 -07:00
Michael Crosby 0ebcbde911 Remove unsupported file
This is no longer needed and is not properly built with the cross
compile scripts anyways.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-14 12:50:51 -07:00
Paul Morie ea6e255f45 Remove unused arg from namespaces.NsEnter
Docker-DCO-1.1-Signed-off-by: Paul Morie <pmorie@gmail.com> (github: pmorie)
2014-07-13 17:48:27 -04:00
Michael Crosby 422824c9d8 Move syncpipe into separate package
This moves the sync pipe into a separate package to help the changes
when moving the API around.

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-11 11:06:00 -07:00
maebashi 16f939a958 fix the order of setns()
Docker-DCO-1.1-Signed-off-by: Takahiro Maebashi <maebashi@iij.ad.jp> (github: maebashi)
2014-06-29 20:05:09 +09:00
Michael Crosby a980a961c1 Return error on shutdown call
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:18:39 -07:00
Michael Crosby bd7d1eb7b6 Fix parent type in sync pipe
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:08:49 -07:00
Michael Crosby e098c02ef7 Update tests for network state
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:06:26 -07:00
Michael Crosby 73ff1addf9 Fix cross compile with syscall
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:03:49 -07:00
Michael Crosby e7916505a3 Add unit test for sync pipe
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:03:49 -07:00
Michael Crosby eb9a561b18 Address review comments
Ensure that the command is killed if we receive an error from the child
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:02:43 -07:00
Alexander Larsson ca9544522e Report child error better (and later)
We use a unix domain socketpair instead of a pipe for the sync pipe,
which allows us to use two-way shutdown. After sending the
context we shut down the write side which lets the child know
it finished reading.

We then block on a read in the parent for the child closing the file
(ensuring we close our version of it too) to sync for when the child
is finished initializing. If the read is non-empty we assume this
is an error report and fail with an error. Otherwise we continue as
before.

This also means we're now calling back the start callback later,
meaning at that point its more likely to have succeeded, as well as
having consumed all the container resources (like volume mounts,
making it safe to e.g. unmount them when the start callback is
called).

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-06-26 14:02:43 -07:00
Michael Crosby f975ff9159 Merge pull request #25 from vishh/network_stats
Adding per container network stats
2014-06-26 13:58:18 -07:00
Glyn Normington 29adc8c29f Improve nsinit usage instructions
nsinit must be run as root.

Tidy up the README somewhat to clarify the distinction between
libcontainer and the nsinit CLI.

Fix some typos in other files.

Docker-DCO-1.1-Signed-off-by: Glyn Normington <gnormington@gopivotal.com> (github: glyn)
2014-06-26 11:57:09 +01:00
Vishnu Kannan 98c2593cdc Refactores network Interface a bit to use NetworkState struct instead of a map for passing runtime information around.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-25 22:51:28 +00:00
Vishnu Kannan edf1e856a0 RuntimeCkpt is now State and the checkpoint file is called state.json.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-25 21:29:04 +00:00
Vishnu Kannan 481552c02b Created a global runtime checkpoint for libcontainer. Got rid of the network specific runtime checkpoint.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-25 19:20:07 +00:00
Vishnu Kannan 9253412ee1 1. Added a basic version of network stats inside network package.
2. Introducing a new checkpoint file 'network.stats' which will contain the network runtime information (veth interface names for now).
3. Adding network stats to 'nsinit stats'.
4. Added a libcontainer Stats API to get both network and cgroup stats

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-25 19:19:10 +00:00
Michael Crosby 5bb250143e Rename to InitPid
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-25 11:42:08 -07:00
Michael Crosby 77dcaac129 Update code based on review comments
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-25 11:36:54 -07:00
Michael Crosby 81e5a3f7a7 Replace pid and started file with State type
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-25 11:36:54 -07:00
Michael Crosby 5c86dd962f Remove generic context and replace with fields
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-24 17:31:03 -07:00
Victor Marmol 60b381e600 Rename Container -> Config.
Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-06-23 17:08:15 -07:00
Michael Crosby d2c7999a57 Fix cross compile for network and node pkgs
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-23 16:23:51 -07:00
Michael Crosby 0023305afc Make MountConfig on container a pointer
Also add unit test for container json files to ensure that the mount
config is read and device nodes are validated.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-23 15:33:30 -07:00
Vishnu Kannan 952b884882 Use internal types in the API instead of duplicating the types.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-23 21:11:01 +00:00
Vishnu Kannan ad5286acd9 Addressed more comments.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-23 20:40:37 +00:00