Commit graph

590 commits

Author SHA1 Message Date
Daniel J Walsh
860fba80eb
Merge pull request #1401 from umohnani8/image
Fix create container failure due to wrong image reference
2018-03-03 10:18:09 -05:00
Sebastien Boeuf
1391c5c2fd crio: Ensure container state is stopped when calling StopContainer()
CRI-O works well with runc when stopping a container because as soon
as the container process returns, it can consider every container
resources such as its rootfs as being freed, and it can proceed
further by unmounting it.

But in case of virtualized runtime such as Clear Containers or Kata
Containers, the same rootfs is being mounted into the VM, usually as
a device being hotplugged. This means the runtime will need to be
triggered after the container process has returned. Particularly,
such runtimes should expect a call into "state" in order to realize
the container process is not running anymore, and it would trigger
the container to be officially stopped, proceeding to the necessary
unmounts.

The way this can be done from CRI-O, without impacting the case of
runc, is to explicitly wait for the container status to be updated
into "stopped" after the container process has returned. This way
CRI-O will call into "state" as long as it cannot see the container
status being updated properly, generating an error after a timeout.

Both PollUpdateStatusStopped() and WaitContainerStateStopped() make
use of go routines in order to support a timeout definition. They
follow the waitContainerStop() approach with chControl.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2018-03-02 14:55:29 -08:00
Mrunal Patel
61a49a111d
Merge pull request #1392 from umohnani8/pid-ns
Enable per pod PID namespace setting
2018-03-02 13:33:14 -08:00
umohnani8
156e21ddf9 Enable per pod PID namespace setting
If the pid namespace mode is set to POD, then the container's namespace
should be set to the namespace of the pod infra container.

Signed-off-by: umohnani8 <umohnani@redhat.com>
2018-03-02 12:04:02 -05:00
umohnani8
e35204c5e0 Fix create container failure due to wrong image reference
When the image name is resolved with the registries from crio.conf only
the resolved name with the first registry is passed to create_container
eventhough there are more registries in the crio.conf file.
Fix this to try the resolved image names with all the registries given in the conf file.

Signed-off-by: umohnani8 <umohnani@redhat.com>
2018-03-02 11:13:51 -05:00
Antonio Murdaca
1b86b57b07
server: prevent double channel close
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-03-02 13:43:09 +01:00
Daniel J Walsh
0a1ae89ba6
Merge pull request #1345 from runcom/fsnotify-hooks
Fsnotify hooks
2018-03-01 12:18:00 -08:00
Antonio Murdaca
0fe2aa6e2f
sandbox_stop: close/remove the netns _after_ stopping the containers
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-22 17:28:23 +01:00
Mrunal Patel
5f7ac28059 Update code for latest k8s
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2018-02-21 11:03:56 -08:00
Antonio Murdaca
ca94095739
server: fsnotify on hooks
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-19 17:05:37 +01:00
Antonio Murdaca
d6c32fa88e
server|cmd: refactor monitors chan
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-16 12:52:25 +01:00
Mrunal Patel
8f5e37a83c
Merge pull request #1249 from theatrus/add-container-stats
Add methods for listing and fetching container stats
2018-02-15 13:29:15 -08:00
Mrunal Patel
ea90be40c4
Merge pull request #1337 from nalind/fix-runasuser-cache
imageService: cache information about images
2018-02-15 11:22:33 -08:00
Yann Ramin
9a86dbabc2 Add logging support for base condition in debug
Signed-off-by: Yann Ramin <atrus@stackworks.net>
2018-02-14 08:10:26 -08:00
Yann Ramin
a2fc41358a Simplify filter block
Signed-off-by: Yann Ramin <atrus@stackworks.net>
2018-02-14 08:10:26 -08:00
Yann Ramin
50c94a9335 Specifying a filter with no filtering expressions is now idempotent
Signed-off-by: Yann Ramin <atrus@stackworks.net>
2018-02-14 08:10:26 -08:00
Yann Ramin
14c1c70407 Add methods for listing and fetching container stats
This uses the previously unusued lib/stats.go code to return data
about container stats to the CRI API. Helpers have been built around
filtering based on the OCI API, and CPU stat reporting has been fixed.

No data on filesystem layer usage is returned at this time.

Fixes one-half of #1248

Signed-off-by: Yann Ramin <atrus@stackworks.net>
2018-02-14 08:10:13 -08:00
Antonio Murdaca
96fb47213e
container_create: correctly set user
We had a bug in ImageStatus where we weren't returning the default
image user if set, thus running all containers as root despite a user
being set in the image config. We weren't populating the Username field
of ImageStatus.
This patch fixes that along with the handling of multiple images based
on the registry patch for multiple images.
It also fixes ListImages to return Username as well.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-14 13:17:20 +01:00
Antonio Murdaca
ab204b6641
sandbox: record whether sb is using host network
We need to record whether the sandbox is using hostnetwok because the
kubelet needs that information when computing pod changes. Without this
patch it could happen that a pod that's using host network is restarted
just because the sandbox's status isn't reporting that it's running
using host network.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-13 11:45:33 +01:00
Antonio Murdaca
a12990d4a0
container_status: expose LogPath as requested by the CRI
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-12 11:38:27 +01:00
Antonio Murdaca
e5fc48a3ca
sandbox: restore portMappings on restart
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-12 11:32:17 +01:00
Antonio Murdaca
c3f1e7aec2
container_create: read ctr annotations for hooks first
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-12 11:32:15 +01:00
Antonio Murdaca
a0157078ad
sandbox: fix sandbox logPath when crio restarts
We weren't setting the logPath of the sandbox when restoring sandboxes
and containers upon a crio restarts. That means that if you restart
CRI-O you get sandboxes with empty logPath. That means that when you're
starting a container in a restored sandbox you get a relative logPath
for the container:

sandboxLogPath: "/var/something"
- restore
sandboxLogPath: ""
- create container foo
containerLogPath: "foo_attempt.log"

With this patch we actually get an absolute path (which is correct):

sandboxLogPath: "/var/something"
- restore
sandboxLogPath: "/var/something"
- create container foo
containerLogPath: "/var/something/foo_attempt.log"

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-02-09 15:54:47 +01:00
Daniel J Walsh
5345c6299a
Merge pull request #1283 from lyft/imagefs-stats-1.9
Implement the stats for the image_fs_info command
2018-02-05 09:06:31 -05:00
Bo Zhao
bfaf35b063 Implement the stats for the image_fs_info command
Signed-off-by: Bo Zhao <bzhao@lyft.com>
2018-01-29 10:01:19 -08:00
Mrunal Patel
6f45c1726e container_attach: Ensure ctl file is closed
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2018-01-25 17:04:01 -08:00
Antonio Murdaca
cf37995d30
container_create: only bind mount /etc/hosts if not provided by k8s
k8s already mounts /etc/hosts from /var/lib/kubelet/pods/<ID>/etc-hosts
even for host network. We shouldn't play with it unless we're running
from crictl for instance.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-01-24 15:06:41 +01:00
Mrunal Patel
ed40d645cd
Merge pull request #1255 from runcom/panics-grpc-getters
server: use grpc getters to avoid panics
2018-01-23 07:43:08 -08:00
W. Trevor King
523326b7ba server/container_create: Factor out setupCapabilities helper
Having a separate function holding the details of this makes reading
createSandboxContainer easier.

While I was moving the code, I've also cleaned up two things:

* The nil capabilities check is now earlier, where before it had been
  between the ALL handling and the non-ALL handling.

* I've added a capPrefixed variable to avoid having multiple
  toCAPPrefixed calls per capability.

Signed-off-by: W. Trevor King <wking@tremily.us>
2018-01-19 11:52:45 -08:00
Antonio Murdaca
8c190a683c
server: use grpc getters to avoid panics
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2018-01-12 16:14:29 +01:00
Daniel J Walsh
23d20c9db5 Allow additional arguments to be passed into hooks
If a packager wants to be able to support addititional arguments on his
hook this will allow them to setup the configuration with these arguments.

For example this would allow a hook developer to add support for a --debug
flag to change the level of debugging in his hook.

In order to complete this task, I had to vendor in the latest
github.com://opencontainers/runtime-tools, which caused me to have to fix a
Mount and Capability interface calls

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-01-09 13:44:16 -05:00
Antonio Murdaca
de0be63495
container_create: set cpuset cpus|mems
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-12-20 19:20:57 +01:00
Nalin Dahyabhai
893aa4e8c7 Be more diligent about cleaning up failed-to-create containers
If server/Server.createSandboxContainer() fails after calling
server/Server.StorageRuntimeServer().CreateContainer(), cleanup logic in
server/Server.CreateContainer() won't try to clean it up, but we still
need to clean up the on-disk container and its layer.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-12-14 14:23:53 -05:00
Nalin Dahyabhai
ff7bbb4f0d Switch to ImageServer.UntagImage in RemoveImage handler
Add an UntagImage() method to pkg/storage/ImageServer, which will check
if the passed-in NameOrID is a name.  If so, it merely removes that name
from the image, removing the image only if it was the last name that the
image had.  If the NameOrID is an image ID, the image is removed, as
RemoveImage() does.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-12-14 14:23:53 -05:00
Nalin Dahyabhai
f3b7065bd8 Return image references from the storage package
The image's canonical reference is a name with a digest of the image's
manifest, so in imageService.ImageStatus() and
imageService.ListImages(), divide the image's name list into tagged and
digested values, and if we have names, add canonical versions.

In Server.ContainerStatus(), return the image name as it was given to us
as the image, and the image digested reference as the image reference.

In Server.ListImages(), be sure to only return tagged names in the
RepoTags field.  In Server.ImageStatus(), also return canonical
references in the RepoDigests field.

In Server.PullImage(), be sure that we consistently return the same
image reference for an image, whether we ended up pulling it or not.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-12-14 14:23:52 -05:00
Antonio Murdaca
afeab27a36
container_exec: fix terminal true process json
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-12-07 20:51:05 +01:00
Daniel J Walsh
b9ffd277b9
Merge pull request #1192 from runcom/no-libkpod
libkpod -> lib rename
2017-12-01 08:44:44 -05:00
Antonio Murdaca
0eaa52c356
Merge pull request #1184 from willstudy/unit_test
Adding unit tests for server/secrets.go
2017-12-01 10:04:30 +01:00
Mrunal Patel
2cae11ba35 Merge pull request #1189 from runcom/fix-apparmor-master
container_create: fix apparmor from container config
2017-11-30 08:56:46 -10:00
Antonio Murdaca
b8bba70f99
libkpod -> lib rename
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-11-30 17:08:26 +01:00
Antonio Murdaca
c8aad704dd
container_create: fix apparmor from container config
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-11-30 16:12:16 +01:00
Antonio Murdaca
902acca4af
container_create: correctly set image and kube envs
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-11-30 12:28:50 +01:00
Antonio Murdaca
c6f68f1bf1
container_exec: use process file with runc exec
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-11-30 11:23:37 +01:00
Liu Chang
c0ad5277e6 Adding unit tests for server/secrets.go
Signed-off-by: Liu Chang <liuchang@qiniu.com>
2017-11-29 17:42:19 +08:00
Antonio Murdaca
87f1ae214f
image_pull: fix image resolver
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-11-28 23:53:18 +01:00
Liu Chang
42800cc96b Adding unit tests for server/utils.go
Signed-off-by: Liu Chang <liuchang@qiniu.com>
2017-11-27 16:01:00 +08:00
Antonio Murdaca
a75362dca0
Add /proc/scsi to masked paths
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-11-22 12:25:43 +01:00
Mrunal Patel
946307e5c2 Make pid namespace sharing optional and disabled by default
We reverse the logic so that pid ns sharing is disabled by default.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2017-11-18 06:47:06 -08:00
Mrunal Patel
d68da8929a
Merge pull request #1149 from weiwei04/share_pid_namespace
share pid namespace for Pod container
2017-11-17 08:12:49 -10:00
Wei Wei
702ab3ee3a share pid namespace for Pod container
Signed-off-by: Wei Wei <weiwei.inf@gmail.com>
2017-11-17 09:56:33 +08:00