194 Commits

Author SHA1 Message Date
8dfebd4607 varlink containers
first pass at adding in the container related endpoints/methods for the libpod
backend. Couple of important notes:

* endpoints that can use a console are not going to be done until we have "remote" console
* several of the container methods should probably be able to stream as opposed to a one-off return

Signed-off-by: baude <bbaude@redhat.com>

Closes: #708
Approved by: baude
2018-05-03 17:31:33 +00:00
27107fdac1 Vendor in latest containers/image and contaners/storage
Made necessary changes to functions to include contex.Context wherever needed

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #640
Approved by: baude
2018-04-19 14:08:47 +00:00
6c5ebb0315 Change container.locked to batched
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #619
Approved by: mheon
2018-04-16 15:18:38 +00:00
8d7635b1ac Change attach to accept a struct containing streams
Comparing Go interfaces, like io.Reader, to nil does not work. As
such, we need to include a bool with each stream telling whether
to attach to it.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #608
Approved by: baude
2018-04-13 18:43:44 +00:00
5e03cec7ec Changes to attach to enable per-stream attaching
This allows us to attach to attach to just stdout or stderr or
stdin, or any combination of these.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #608
Approved by: baude
2018-04-13 18:43:44 +00:00
4b25039cf4 Fix locking interaction in batched Exec() on container
Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #610
Approved by: giuseppe
2018-04-13 16:36:09 +00:00
1700f2b238 Use buildah commit for podman commit
Resolves: #586 and #520
Signed-off-by: baude <bbaude@redhat.com>

Closes: #592
Approved by: mheon
2018-04-10 13:31:59 +00:00
b1a8d769b8 Stopping a stopped container should not be an error
Resolves: #575

Signed-off-by: baude <bbaude@redhat.com>

Closes: #588
Approved by: mheon
2018-04-03 18:37:41 +00:00
98b19aeb0c Refactor dependency checks from init() into public API
Instead of checking during init(), which could result in major
locking issues when used with pods, make our dependency checks in
the public API instead. This avoids doing them when we start pods
(where, because of the dependency graph, we can reasonably say
all dependencies are up before we start a container).

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #577
Approved by: rhatdan
2018-04-03 14:57:16 +00:00
4d4646d09b Do not require Init() before Start()
This will help dependency races

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #577
Approved by: rhatdan
2018-04-03 14:57:16 +00:00
f7c8dd5836 Stage 4 Image cleanup
Cull funcs from runtime_img.go which are no longer needed.  Also, fix any remaining
spots that use the old image technique.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #532
Approved by: mheon
2018-03-23 15:35:37 +00:00
38a1b2f16d Image library stage 4 - create and commit
Migrate the podman create and commit subcommandis to leverage the images library.  I also had
to migrate the cmd/ portions of run and rmi.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #498
Approved by: mheon
2018-03-20 16:20:12 +00:00
8840b92da6 Remove ability to specify mount label when mounting
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #506
Approved by: rhatdan
2018-03-16 13:35:23 +00:00
1856703e38 Add additional debug logging
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #482
Approved by: baude
2018-03-15 17:45:11 +00:00
55f2f58145 Add StartAndAttach() API endpoint for containers
This solves our prior problems with attach races by ensuring the
order is correct.

Also contains substantial cleanups to the attach code.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #482
Approved by: baude
2018-03-15 17:45:11 +00:00
02a26c2934 Implement container restarting
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #482
Approved by: baude
2018-03-15 17:45:11 +00:00
40d302be8f Modify pod API to move Init() into Start()
Separate Init() and Start() does not make sense on the pod side,
where we may have to start containers in order to initialize
others due to dependency orders.

Also adjusts internal containers API for more code sharing.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #478
Approved by: rhatdan
2018-03-13 13:54:45 +00:00
54f32f2cc0 Convert bind mounts to use DB field
Refactors creation of bind mounts into a separate function that
can be called from elsewhere (e.g. pod start or container
restart). This function stores the mounts in the DB using the
field established last commit.

Spec generation now relies upon this field in the DB instead of
manually enumerating files to be bind mounted in.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #462
Approved by: baude
2018-03-08 16:40:21 +00:00
fcc3663355 Move internal function resizeTty to container_internal
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #462
Approved by: baude
2018-03-08 16:40:21 +00:00
d23b9fd4ed Refactor saving OCI spec to disk into separate function
It will be needed for restarting containers

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #462
Approved by: baude
2018-03-08 16:40:21 +00:00
4344639508 podman import, load, and commit are too verbose
The progress should not be show for import, load, and commit.  It makes machine
parsing of the output much more difficult.  Also, each command should output an
image ID or name for the user.

Added a --verbose flag for users that still want to see progress.

Resolves issue #450

Signed-off-by: baude <bbaude@redhat.com>

Closes: #456
Approved by: rhatdan
2018-03-07 20:59:11 +00:00
bbf9a313c3 attach: set the terminal size and handle SIGWINCH
Notify conmon when the terminal size changes.  Use the same notification
to set the correct initial size.

Closes: https://github.com/projectatomic/libpod/issues/351

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #448
Approved by: baude
2018-03-06 20:47:46 +00:00
c5dc7f81fc Replace usage of runc with runtime
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
fa5f99effa Convert exec session tracking to use a dedicated struct
This will behave better if we need to add anything to it at a
later date - we can add fields to the struct without breaking
existing BoltDB databases.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
83d7ae6506 Fix gofmt & golint
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
780baec1d9 Relax locking in Exec()
This allows containers to be used by `ps` and other commands
while they have ongoing exec sessions. Concurrent exec should
also work but is not tested.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
70baafc1c7 Ensure that Cleanup() will not run on active containers
This ensures that containers with active exec sessions will not
have storage unmounted under them or network namespaces destroyed

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
8b87a17f56 Add tracking for exec session IDs
Exec sessions now have an ID generated and assigned to their PID
and stored in the database state. This allows us to track what
exec sessions are currently active.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
345bfafee2 Rework exec to enable splitting to retrieve exec PID
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:50 +00:00
920b66707e Small fixes to container Exec
Fix an error message, and always set Privileged if the container
is also privileged.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:50 +00:00
5e7979f016 Address review comments
Review comments to delete WithNoNew function and its append.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #369
Approved by: rhatdan
2018-02-24 09:15:47 +00:00
831dc48883 Add support for --no-new-privs
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #369
Approved by: rhatdan
2018-02-24 09:15:47 +00:00
eafbe76ebe Refactor spec generation in libpod into a function
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #386
Approved by: baude
2018-02-23 04:25:47 +00:00
3d395767d8 Implement --image-volumes for create and run
--image-volumes tells podman what to do with the image volumes in the image config
There are 3 options: bind, tmpfs, and ignore
bind puts the volume contents in /var/lib/containers/storage/container-id/volumes/vol-dir
and bind mounts it into the container at /vol-dir
tmpfs mounts /vol-dir as a tmps into the container
ignore doesn't mount the image volumes onto the container

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #377
Approved by: rhatdan
2018-02-22 15:14:00 +00:00
b07c8d6a73 Fix libpod to use given CGroup parent instead of a hardcoded one
Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #319
Approved by: TomSweeneyRedHat
2018-02-09 20:11:07 +00:00
3921f10a72 cleanup network stack as well as storage when container shuts down.
This patch will cleanup the network stack when the container exits

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-02-08 06:42:21 -05:00
ca7ebcac64 Change pause so only running containers are valid
Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-02-07 10:47:43 -05:00
8fbfb93947 Error on attempting to restart container
Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #304
Approved by: baude
2018-02-07 01:56:11 +00:00
6ba6ecf59b Migrate Create|Commit to ginkgo
Migrate create and commit bats tests to the ginkgo
test suite.  In doing so, some structures had to be
moved to pkg/podmanstructs/podmanstructs.go so we
could do better verification of test results.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #286
Approved by: rhatdan
2018-02-02 22:44:40 +00:00
f02d72fb76 libpod/container_api: Set hostname in ENV
The container's hostname should be set as an environment
variable for the container.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #273
Approved by: baude
2018-01-30 15:21:10 +00:00
c60d8a0671 Add StopWithTimeout API function for containers
Normal Stop should not need a timeout, and should use the default
Add a function that does accept a timeout aside it

Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #272
Approved by: rhatdan
2018-01-30 05:02:12 +00:00
5c3e4cfa62 Override hostname for container
Adds the ability to override the container's hostname.  Also, uses
the first twelve characters of the container ID as the default hostname
if none is provided.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #248
Approved by: baude
2018-01-21 17:24:49 +00:00
a4701b5631 Add --dns-search, --dns-opt, --dns-server and --add-host.
Each of these options are destructive in nature, meaning if the user
adds one of them, all current ones are removed from the produced
resolv.conf.

* dns-server allows the user to specify dns servers.
* dns-opt allows the user to specify special resolv.conf options
* dns-search allows the user to specify search domains

The add-host option is not destructive and truly just adds the host
to /etc/hosts.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #231
Approved by: mheon
2018-01-19 15:42:25 +00:00
64d2190ec1 Split container.go into three files
Weighing in at ~1700 lines, container.go is just too big. Split
it into three files: core structs and accessors (container.go),
public API (container_api.go), and internal functions
(container_internal.go).

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2018-01-18 11:48:20 -05:00