Commit Graph

5443 Commits

Author SHA1 Message Date
Peng Tao
6f46be2f2e
Merge pull request #962 from egernst/config-update
config: make virtio-fs part of standard kernel
2020-10-16 10:06:02 +08:00
Fupan Li
cacb27fe4b
Merge pull request #942 from Tim-Zhang/optimize-error-handling
agent: Optimize error handling
2020-10-16 09:15:22 +08:00
Salvador Fuentes
18553459d1
Merge pull request #961 from chavafg/topic/update-k8s-1.18
versions: Update Kubernetes, containerd, cri-o and cri-tools
2020-10-15 16:54:21 -05:00
Eric Ernst
d3c9862059 config: make virtio-fs part of standard kernel
Basic virtio-fs support has made it upstream in the Linux kernel, as
well as in QEMU and Cloud Hypervisor. Let's go ahead and add it to the
standard configuration.

Since the device driver / DAX handling is still in progress for
upstream, we will want to still build a seperate experimental kernel for
those who are comfortable trading off bleeding edge stability/kernel
updates for improved FIO numbers.

Fixes: #963

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-15 12:21:41 -07:00
Julio Montes
238e4562e0
Merge pull request #965 from jodh-intel/2.0-dev-agent-fix-crashers
agent: fix crashers if API requests empty
2020-10-15 09:53:11 -05:00
Peng Tao
6612b0c4bf
Merge pull request #953 from liubin/fix/952
rustjail: add length check for uid_mappings in rootless euid mapping
2020-10-15 20:42:09 +08:00
Peng Tao
bcda074e5a
Merge pull request #964 from liubin/fix/957-use-regex-to-filter-kata-contaienrs
kata-monitor: use regexp to check if runtime is kata containers
2020-10-15 20:41:54 +08:00
Tim Zhang
6ba294a11e agent: remove unwrap() for e.as_errno()
Use `{:?}` to print `e.as_errno()` instead of using `{}`
to print `e.as_errno().unwrap().desc()`.

Avoid panic only caused by error's content.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 19:46:00 +08:00
Tim Zhang
e77482fe16 agent: Use ? instead of match when the error returns directly
It's more clear and more readable.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 19:45:55 +08:00
bin liu
1b7ed32836 kata-monitor: use regexp to check if runtime is kata containers
To support a few common configurations for Kata, including:

- `io.containerd.kata.v2`
- `io.containerd.kata-qemu.v2`
- `io.containerd.kata-clh.v2`

`kata-monintor` changes to use regexp instead of direct string comparison.

Fixes: #957

Signed-off-by: bin liu <bin@hyper.sh>
2020-10-15 18:42:44 +08:00
Tim Zhang
47ff2fb9a0 agent: use anyhow context to attach context to Error instead of match
Context is clearer than match for these situations.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 18:16:54 +08:00
Tim Zhang
2f690a2bb0 agent: remove useless match
Remove useless match.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 18:16:54 +08:00
James O. D. Hunt
cb6231c1bc
Merge pull request #930 from YchauWang/update-docs-2.0-6
docs: update the build kata containers kernel document
2020-10-15 11:15:25 +01:00
Tim Zhang
1d8def6663 agent: Use ok_or_else instead of match for Option -> Result
Using ok_or is clearer than match.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 18:15:14 +08:00
James O. D. Hunt
8495306641 agent: Fix crasher if AddARPNeighbors request empty
Check if the ARP neighbours specified in the `AddARPNeighbors` API is
set before using it to avoid crashing the agent.

Fixes: #955.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-10-15 11:12:40 +01:00
James O. D. Hunt
3d084c7d23 agent: Fix crasher if UpdateRoutes request empty
Check if the routes specified in the `UpdateRoutes` API is set before
using it to avoid crashing the agent.

Fixes: #949.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-10-15 11:12:38 +01:00
James O. D. Hunt
5615e5a7fe agent: Fix crasher if UpdateInterface request empty
Check if the interface specified in the `UpdateInterface` API is set
before using it to avoid crashing the agent.

Fixes: #950.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-10-15 11:12:35 +01:00
Tim Zhang
0dce817ebb agent: replace match Result with or_else
`or_else` is suitable for more complicated situations.
We can use it to return Ok in Err handling.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 17:58:51 +08:00
Tim Zhang
7bf4073d8d agent: replace unnecessary match Result with map_err
Replace `match Result` whose Ok hand is useless.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 17:58:43 +08:00
Tim Zhang
7f9e5913e0 agent: replace check! with map_err for readability
It's ambiguous and not easy to read to call method use macro.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 17:37:33 +08:00
Tim Zhang
09aca49ed7 agent: remove check! in child process because we cant' see logs.
The check macro will log the errors but the log in child process can't
be seen, just ignore it.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 17:33:16 +08:00
Tim Zhang
a18899f1a3 agent: refactor namespace::setup to optimize error handling
- Replace the return value with anyhow::Result.
- Remove if let Err.
- Remove match.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 17:28:20 +08:00
Tim Zhang
a3c64e5ce5 agent: replace if let Err with or_else
Fixes #934

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 17:27:10 +08:00
Tim Zhang
6ffa8283f0 agent: replace if let Err with map_err
Fixes #934

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-10-15 17:26:40 +08:00
bin liu
863f918a2c rustjail: add length check for uid_mappings in rootless euid mapping
This might be a copy miss, gid_mappings is checked twice, one should
be uid_mappings.

Fixes: #952

Signed-off-by: bin liu <bin@hyper.sh>
2020-10-15 16:43:52 +08:00
Salvador Fuentes
720eab78bb versions: Update Kubernetes, containerd, cri-o and cri-tools
Kubernetes: from 1.17.3 to 1.18.9
CRI-O: from 0eec454168e381e460b3d6de07bf50bfd9b0d082 (1.17) to 1.18.3
Containerd: from 3a4acfbc99aa976849f51a8edd4af20ead51d8d7 (1.3.3) to 1.3.7
cri-tools: from 1.17.0 to 1.18.0

Fixes: #960.
Depends-on: github.com/kata-containers/tests#2958

Signed-off-by: Salvador Fuentes <salvador.fuentes@intel.com>
2020-10-14 18:02:37 -04:00
Eric Ernst
71be16c401
Merge pull request #933 from egernst/cgroup-updates
cgroup and cpuset fixes from 1.x
2020-10-14 08:41:52 -07:00
Peng Tao
225ed59202
Merge pull request #941 from jodh-intel/2.0-dev-update-upgrading-doc
docs: Update upgrading guide
2020-10-14 23:29:08 +08:00
Eric Ernst
8132417512
Merge pull request #947 from bergwolf/pod-updates
agent: fix panic on malformed device resource in container update
2020-10-14 08:27:10 -07:00
Peng Tao
fc6468efdb agent: fix panic on malformed device resource in container update
Somehow containerd is sending a malformed device in update API. While it
should not happen, we should not panic either.

Fixes: #946
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-10-14 13:27:23 +08:00
Eric Ernst
d8a8fe47fb cpuset: don't set cpuset.mems in the guest
Kata doesn't map any numa topologies in the guest. Let's make sure we
clear the Cpuset fields before passing container updates to the
guest.

Note, in the future we may want to have a vCPU to guest CPU mapping and
still include the cpuset.Cpus. Until we have this support, clear this as
well.

Fixes: #932

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-13 15:54:03 -07:00
Eric Ernst
88cd712876 sandbox: consider cpusets if quota is not enforced
CPUSet cgroup allows for pinning the memory associated with a cpuset to
a given numa node. Similar to cpuset.cpus, we should take cpuset.mems
into account for the sandbox-cgroup that Kata creates.

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-13 15:54:03 -07:00
Eric Ernst
77a463e57a cpuset: support setting mems for sandbox
CPUSet cgroup allows for pinning the memory associated with a cpuset to
a given numa node. Similar to cpuset.cpus, we should take cpuset.mems
into account for the sandbox-cgroup that Kata creates.

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-13 15:54:03 -07:00
Eric Ernst
2d690536b8 cpuset: add cpuset pkg
Pulled from 1.18.4 Kubernetes, adding the cpuset pkg for managing
CPUSet calculations on the host. Go mod'ing the original code from
k8s.io/kubernetes was very painful, and this is very static, so let's
just pull in what we need.

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-13 15:54:03 -07:00
James O. D. Hunt
5b5200037a docs: Update upgrading guide
Update the upgrading guide for 2.0.

Fixes: #928.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-10-13 14:00:13 +01:00
Fupan Li
25cdf2d728
Merge pull request #931 from dgibson/bug703
Forward port device conflict fixes from Kata 1 / Go agent
2020-10-13 15:59:17 +08:00
Ychau Wang
0e0564a55d docs: update the build kata containers kernel document
Update the build kata containers kernel document for 2.0 release. Fixed
the 1.x release project paths and urls, using the kata-containers
project file paths and urls.

Fixes: #929

Signed-off-by: Ychau Wang <wangyongchao.bj@inspur.com>
2020-10-13 15:12:53 +08:00
David Gibson
ae6b8ec747 agent/device: Check type as well as major:minor when looking up devices
To update device resource entries from host to guest, we search for
the right entry by host major:minor numbers, then later update it.
However block and character devices exist in separate major:minor
namespaces so we could have one block and one character device with
matching major:minor and thus incorrectly update both with the details
for whichever device is processed second.

Add a check on device type to prevent this.

Port from the Kata 1 Go agent
https://github.com/kata-containers/agent/commit/27ebdc9d2761

Fixes: #703

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-13 16:26:52 +11:00
David Gibson
859301b009 agent/device: Index all devices in spec before updating them
The agent needs to update device entries in the OCI spec so that it
has the correct major:minor numbers for the guest, which may differ
from the host.

Entries in the main device list are looked up by device path, but
entries in the device resources list are looked up by (host)
major:minor.  This is done one device at a time, updating as we go in
update_spec_device_list().

But since the host and guest have different namespaces, one device
might have the same major:minor as a different device on the host.  In
that case we could update one resource entry to the correct guest
values, then mistakenly update it again because it now matches a
different host device.

To avoid this, rather than looking up and updating one by one, we make
all the lookups in advance, creating a map from (host) device path to
the indices in the spec where the device and resource entries can be
found.

Port from the Go agent in Kata 1,
https://github.com/kata-containers/agent/commit/d88d46849130

Fixes: #703

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-13 16:26:26 +11:00
David Gibson
2477c355bc agent/device: Forward port update_spec_device_list() unit test
The Kata 1 Go agent included a unit test for updateSpecDeviceList, but no
such unit test exists for the Rust agent's equivalent
update_spec_device_list().  Port the Kata1 test to Rust.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-13 16:25:58 +11:00
David Gibson
08d80c1aaa agent/device: update_spec_device_list() should error if dev not found
If update_spec_device_list() is given a device that can't be found in the
OCI spec, it currently does nothing, and returns Ok(()).  That doesn't
seem like what we'd expect and is not what the Go agent in Kata 1 does.

Change it to return an error in that case, like Kata 1.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-13 16:25:36 +11:00
Eric Ernst
12cc0ee168 sandbox: don't constrain cpus, mem only cpuset, devices
Allow for constraining the cpuset as well as the devices-whitelist . Revert
sandbox constraints for cpu/memory, as they break the K8S use case. Can
re-add behind a non-default flag in the future.

The sandbox CPUSet should be updated every time a container is created,
updated, or removed.

To facilitate this without rewriting the 'non constrained cgroup'
handling, let's add to the Sandbox's cgroupsUpdate function.

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-12 21:31:27 -07:00
Eric Ernst
b6cf68a985 cgroups: add ability to update CPUSet
Add function for applying a cpuset change to a cgroup

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-12 21:31:27 -07:00
Eric Ernst
b812d4f7fa virtcontainers: add method for calculating cpuset for sandbox
Calculate sandbox's CPUSet as the union of each of the container's
CPUSets.

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-12 21:31:27 -07:00
Peng Tao
c88820454d
Merge pull request #739 from jodh-intel/2.0-dev-containerd-install-docs
docs: Add containerd install guide
2020-10-13 11:48:56 +08:00
Peng Tao
16a6427ca9
Merge pull request #923 from liubin/fix/simplify-codes
agent: simplify codes
2020-10-13 09:54:46 +08:00
Eric Ernst
2e72972cd7
Merge pull request #910 from egernst/fix-parsing
agent: fix errorneous parsing for guest block size
2020-10-12 12:40:02 -07:00
Eric Ernst
f63f740545 agent: fix errorneous parsing for guest block size
We were assuming base 10 string before, when the block size from sysfs
is actually a hex string. Let's fix that.

Fixes: #908

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2020-10-12 11:18:39 -07:00
James O. D. Hunt
43d70a32df docs: Add containerd install guide
Create a containerd installation guide and a new `kata-manager` script
for 2.0 that automated the steps outlined in the guide.

Also cleaned up and improved the installation documentation in various
ways, the most significant being:

- Added legacy install link for 1.x installs.
- Official packages section:
  - Removed "Contact" column (since it was empty!)
  - Reworded "Versions" column to clarify the versions are a minimum
    (to reduce maintenance burden).
  - Add a column to show which installation methods receive automatic updates.
  - Modified order of installation options in table and document to
    de-emphasise automatic installation and promote official packages
    and snap more.
- Removed sections no longer relevant for 2.0.

Fixes: #738.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-10-12 17:54:53 +01:00
Fupan Li
27634982f7
Merge pull request #915 from liubin/fix/914-use-macro-to-simplify-codes
agent: use macro to simplify parse_cmdline function in config.rs
2020-10-12 22:23:30 +08:00