Commit Graph

2192 Commits

Author SHA1 Message Date
Hui Zhu
a733f537e5 runtime: newContainer: Handle the annotations of SWAP
This commit add code to handle the annotations
"io.katacontainers.container.resource.swappiness" and
"io.katacontainers.container.resource.swap_in_bytes".
It will set the value of "io.katacontainers.resource.swappiness" to
c.config.Resources.Memory.Swappiness and set the value of
"io.katacontainers.resource.swap_in_bytes" to
c.config.Resources.Memory.Swap.

Fixes: #2201

Signed-off-by: Hui Zhu <teawater@antfin.com>
2021-07-19 23:20:46 +08:00
Hui Zhu
2c835b60ed ContainerConfig: Set ocispec.Annotations to containerConfig.Annotations
ocispec.Annotations is dropped in ContainerConfig.
This commit let it to be set to containerConfig.Annotations in
ContainerConfig.

Fixes: #2201

Signed-off-by: Hui Zhu <teawater@antfin.com>
2021-07-19 23:20:43 +08:00
Hui Zhu
243d4b8689 runtime: Sandbox: Add addSwap and removeSwap
addSwap will create a swap file, hotplug it to hypervisor as a special
block device and let agent to setup it in the guest kernel.
removeSwap will remove the swap file.

Just QEMU support addSwap.

Fixes: #2201

Signed-off-by: Hui Zhu <teawater@antfin.com>
2021-07-19 23:20:40 +08:00
Hui Zhu
e1b91986d7 runtime: Update golang proto code for AddSwap
Fixes: #2201

Signed-off-by: Hui Zhu <teawater@antfin.com>
2021-07-19 23:20:37 +08:00
Hui Zhu
4f066db8da agent: agent.proto: Add AddSwap
Add new fuction AddSwap.  When agent get AddSwap, it will get the device
name from PCIPath and set the device as the swap device.

Fixes: #2201

Signed-off-by: Hui Zhu <teawater@antfin.com>
2021-07-19 23:20:34 +08:00
Fabiano Fidêncio
11d84cca46 Merge pull request #2229 from lifupan/fix_virtiofsd
virtiofsd: fix the issue of missing stop virtiofsd
2021-07-19 13:34:59 +02:00
Bin Liu
b94ebc30b4 Merge pull request #2235 from Tim-Zhang/vsock-exporter-async
vsock-exporter: switch to tokio runtime
2021-07-19 17:06:14 +08:00
Fabiano Fidêncio
462e445d2f Merge pull request #2261 from ManaSugi/fix/oci-hooks-explanation
config: Fix description for OCI hooks
2021-07-19 10:38:16 +02:00
Fabiano Fidêncio
f8d71eb96b Merge pull request #2253 from lifupan/fix_socket_address
shimv2: fix the issue of kata-runtime exec failed
2021-07-19 10:38:06 +02:00
Eryu Guan
35cbc93dee agent: clear MsFlags if the option has clear flag set
'FLAGS' hash map has bool to indicate if the flag should be cleared or
not. But in parse_mount_flags_and_options() we set the flag even 'clear'
is true. This results in a 'rw' mount being mounted as 'MS_RDONLY'.

Fixes: #2262
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
2021-07-19 11:50:10 +08:00
Manabu Sugimoto
ff87da721b config: Fix description for OCI hooks
- Update url for osbuilder
- Fix typo about poststart

Fixes: #2260

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2021-07-18 16:47:19 +09:00
Fabiano Fidêncio
fcc93b0074 shim-v2: Be compatible with the old runtime options
Seems that at least some versions of container, when using ConifgPath,
still rely on the runtime options and its APIs from the not in use
anymore github.com/containerd/cri-containerd/pkg/api/runtimeoptions/v1.

The fact backward compat breaks when moving from the old to the new
runtime options, which happened as part of f60641a6e6d, strongly feels
like a containerd bug.  Regardless, we can easily work this around on
our side without much hassle.

Just by importing old runtime options the unmarshalling doesn't break
anymore and we can easily check whether getting the options fails or not
and fallback to the old way if it does.

Fixes: #2258

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-18 00:07:57 +02:00
fupan.lfp
8e0daf6780 shimv2: fix the issue of kata-runtime exec failed
Commit 32c9ae1388 upgrade the
containerd vendor, which used the socket path to replace
the abstract socket address for socket listen and dial, and
there's an bug in containerd's abstract socket dialing.

Thus we should replace our monitor and exec socket server
with the socket path to fix this issue.

Fixes: #2238

Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
2021-07-16 11:41:09 +08:00
fupan.lfp
5371b9214f mount: fix the issue of missing check file exists
It's better to check whether the destination file exists
before creating them, if it had been existed, then return
directly.

Fixes: #2247

Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
2021-07-15 18:09:33 +08:00
Eric Ernst
acf6932863 agent: update tokio to 1.8.1
Update to latest tokio to address RUSTSEC-2021-0072:
 Task dropped in wrong thread when aborting `LocalSet` task

Update the toml to specify just 1.x for the tokio version.

Fixes: #2165

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2021-07-14 17:18:21 -07:00
Fabiano Fidêncio
3a9ecbcca5 Merge pull request #2231 from liubin/fix/2230-register-defer-callback-at-early-stage
runtime: Register defer function at early stage
2021-07-14 17:50:48 +02:00
fupan.lfp
34828df9a1 virtiofsd: fix the issue of missing stop virtiofsd
The virtiofsd's PID wan't assigned the right pid,
which will result skipping kill it.

Fixes: #2228

Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
2021-07-14 21:07:10 +08:00
Tim Zhang
73d3798cb1 vsock-exporter: switch to tokio runtime
Make the vsock-exporter async totally using tokio runtime.
And delay the timing of the connection to trace-forwarder so that
it is easy to reconnect when the connection was broken.

Fixes: #2234

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-07-14 20:16:05 +08:00
Fabiano Fidêncio
f4fbf723e1 runtime: Update vendored code
The go vendored code is not up-to-date and the newly added check for
that caught this up as part of
https://github.com/kata-containers/kata-containers/pull/2223/checks?check_run_id=3056830309

Let's take advantage of the `make vendor` target and update the vendored
code. :-)

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-14 13:59:41 +02:00
Fabiano Fidêncio
5e69b498ed trace-forwarder: Add make vendor
This has a similar intent as the go code, but not totally equal.  For
the go code we want to ensure that the vendored code is up-to-date,
while here we want to ensure that `cargo vendor` actually works.

We happened to release a few tarballs where `cargo vendor` didn't work
and it causes some pain for downstream maintainers.

Related: #2159

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-14 13:59:41 +02:00
Fabiano Fidêncio
a104f13230 agent: Add make vendor
This has a similar intent as the go code, but not totally equal.  For
the go code we want to ensure that the vendored code is up-to-date,
while here we want to ensure that `cargo vendor` actually works.

We happened to release a few tarballs where `cargo vendor` didn't work
and it causes some pain for downstream maintainers.

Related: #2159

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-14 13:59:41 +02:00
Fabiano Fidêncio
579b3f34c2 runtime: Add make vendor
Let's add this target so we can actually enforce, as part of the static
checks (which will be added in a follow-up commit), that our vendored go
code is up-to-date.

Related: #2159

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-14 13:59:40 +02:00
Fabiano Fidêncio
930ca55d02 runtime: Add make handle_vendor
This will help us to ensure that we always update the vendored code when
needed.   Right now we've been lacking behind and we tend to realise
something change during the next mandatory update, which is not exactly
optimal.

Related: #2159

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-14 13:59:40 +02:00
bin
39546a1070 runtime: delete not used functions
Delete some not used functions in sandbox.go

Fixes: #2230

Signed-off-by: bin <bin@hyper.sh>
2021-07-14 19:42:50 +08:00
bin
d0bc148fe0 runtime: Register defer function at early stage
Register defer function at early stage ensure that
it can be called if the startSandbox fails.

Fixes: #2230

Signed-off-by: bin <bin@hyper.sh>
2021-07-14 17:20:53 +08:00
Tim Zhang
7960689ef7 tracing: replace SimpleSpanProcessor with BatchSpanProcessor
This change make tokio could be use in vsock-exporter.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-07-14 15:59:52 +08:00
bin
350acb2d6e virtcontainers: refactoring code for error handling in sandbox
Use a defined error variable replade inplace error, and shortcut
for handling errors returned from function calls.

Fixes: #2187

Signed-off-by: bin <bin@hyper.sh>
2021-07-14 14:28:58 +08:00
bin
858f39ef75 virtcontainers: update wrong comments for code
Some comments/URL are old or wrong, update them
to the correct ones.

Fixes: #2187

Signed-off-by: bin <bin@hyper.sh>
2021-07-14 14:28:57 +08:00
bin
e0a19f6a16 virtcontainers: update API documentation
Some functions add context as its first parameter,
the documentation should update.

Fixes: #2187

Signed-off-by: bin <bin@hyper.sh>
2021-07-14 14:28:57 +08:00
Fabiano Fidêncio
8c4dd3b421 Merge pull request #2199 from Tim-Zhang/tracing-enhance
trace-forwarder: Add option rustflags, target, build-type for the make
2021-07-13 10:16:21 +02:00
Tim Zhang
6999dccaa8 trace-forwarder: Add option rustflags, target, build-type for the make
Support rust-flags, target and build-type.

Fixes: #2215

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-07-13 11:35:46 +08:00
Eric Ernst
feeb1ef8b1 Merge pull request #2212 from lifupan/fix_virtiofsd
qemu: stop the virtiofsd specifically
2021-07-12 13:56:04 -07:00
Chelsea Mafrica
61b1a6732b Merge pull request #2179 from bporter816/bporter816/refactor-tracing
tracing: Consolidate tracing into a new katatrace package
2021-07-12 12:42:01 -04:00
bin
9081bee2fd runtime: return error if clh's binary has not a normal stat
When checking clh's binary path if valid, return error even
though the error is not a IsNotExist error.

And add errors to log filed when errors occurred.

Fixes: #2208

Signed-off-by: bin <bin@hyper.sh>
2021-07-12 11:16:35 +08:00
Benjamin Porter
b10e3e22b5 tracing: Consolidate tracing into a new katatrace package
Removes custom trace functions defined across the repo and creates
a single trace function in a new katatrace package. Also moves
span tag management into this package and provides a function to
dynamically add a tag at runtime, such as a container id, etc.

Fixes #1162

Signed-off-by: Benjamin Porter <bporter816@gmail.com>
2021-07-11 14:19:51 -05:00
David Gibson
1ab72518b3 agent: Fix to parsing of /proc/self/mountinfo
get_mounts() parses /proc/self/mountinfo in order to get the mountpoints
for various cgroup filesystems.  One of the entries in mountinfo is the
"device" for each filesystem, but for virtual filesystems like /proc, /sys
and cgroups, the device entry is arbitrary.  Depending on the exact rootfs
setup, it can end up being "-".

This breaks get_mounts() because it uses " - " as a separator.  There
really is a " - " separator in mountinfo, but in this case the device entry
shows up as a second one.  Fix this, by changing a split to a splitn, which
will effectively only consider the first " - " in the line.

While we're there, make the warning message more useful, by having it
actually show which line it wasn't able to parse.

fixes #2182

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-07-10 19:30:27 +10:00
fupan.lfp
8f76626fd6 qemu: stop the virtiofsd specifically
We'd better stop the virtiofsd specifically after stop qemu,
instead of depending on the qemu's termination to notify virtiofsd
to exit.

Fixes: #2211

Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
2021-07-10 17:26:19 +08:00
Fabiano Fidêncio
da3de3c2eb shim-v2: Fix gosimple issue on utils_test.go
For some reason our static check started to get opinionated about code
that's been there for ages.

One of the suggestions is to improve:

```
INFO: Running golangci-lint on /home/fidencio/go/src/github.com/kata-containers/kata-containers/src/runtime/containerd-shim-v2
utils_test.go:76:36: S1039: unnecessary use of fmt.Sprintf (gosimple)
	testDir, err = ioutil.TempDir("", fmt.Sprintf("shimV2-"))
```

And that's what this PR is about.

Fixes: #2204

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-09 17:24:51 +02:00
Fabiano Fidêncio
305fb0547d virtcontainers: Fix gosimple issue on client.go
For some reason our static check started to get opinionated about code
that's been there for ages.

One of the suggestions is to improve:
```
INFO: Running golangci-lint on /home/fidencio/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/client
client.go:431:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple)
	if strings.HasPrefix(sock, "mock:") {
```

And that's what this PR is about.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-09 17:18:08 +02:00
Fabiano Fidêncio
89cf168c92 virtcontainers: Ignore a staticcheck error on cpuset.go
First of all, cpuset.go just comes from kubernetes and we shouldn't be
doing much with this file apart from updating it every now and then
(but that's material for another PR).

Right now, due to some change on the static checks we use as part of our
CI, we started getting issues as:
```
INFO: Running golangci-lint on /home/fidencio/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/cpuset
cpuset.go:60:2: SA4005: ineffective assignment to field Builder.done (staticcheck)
	b.done = true
```

For those, let's just ignore the lint and move on.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-07-09 17:17:12 +02:00
Jakob Naucke
9577e54e2a Merge pull request #2168 from Jakob-Naucke/fix-cc-suse-s390x
runtime: Use CC=gcc on all RPM-based s390x
2021-07-09 11:07:35 +02:00
Jakob Naucke
e8ec18a9d8 Merge pull request #2027 from Jakob-Naucke/virtio-blk-ccw
s390x: Enable virtio-blk-ccw
2021-07-08 18:22:44 +02:00
Jakob Naucke
28b2c629e3 runtime: Use CC=gcc on SUSE s390x too
This setting is required, as it is on Fedora-likes.

Fixes: #2167
Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2021-07-08 15:01:32 +02:00
Jakob Naucke
cfd690b638 virtcontainers: Use virtio-blk-ccw on s390x
if virtio-blk-pci were to be used

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2021-07-08 14:59:47 +02:00
Jakob Naucke
8758ce26b7 agent: Enable virtio-blk-ccw
Forward-port of https://github.com/kata-containers/agent/pull/600.
Enable virtio-blk-ccw devices in agent (virtio-blk for s390x, already
enabled in runtime).

Fixes: #2026

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2021-07-08 14:59:47 +02:00
James O. D. Hunt
a33d6bae63 forwarder: Add dump only option
Added a `--dump-only` option which disables forwarding of trace spans.
This essentially makes the forwarder a NOP but can be useful for testing
purposes.

Fixes: #2132.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-07-08 13:12:17 +01:00
Fabiano Fidêncio
432296ae7a Merge pull request #2197 from lifupan/fix_leak_hypervisor
shimv2: fix the issue of leaking the hypervisor processes
2021-07-08 13:49:37 +02:00
fupan.lfp
4c809a53d2 shimv2: fix the issue of leaking the hypervisor processes
Since we only send an shutdown qmp command to qemu when do
stopSandbox, and didn't wait until qemu process's exit, thus
we'd better to make sure it had exited when shimv2 terminated.
Thus here to do the last cleanup of the hypervisor.

Fixes: #2198

Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
2021-07-08 15:43:58 +08:00
Bo Chen
d08603bebb runtime: Remove the version check for cloud hypervisor
It looks like the version check for cloud hypervisor (clh) was added
initially when clh was actively evolving its API. We no longer need the
version check as clh API has been fairly stable for its recent releases.

Fixes: #1991

Signed-off-by: Bo Chen <chen.bo@intel.com>
2021-07-06 18:42:59 -07:00
Tim Zhang
3f1aa8ff91 Merge pull request #2084 from liubin/fix/2082-refactor-vc-pkg-oci
runtime: refact virtcontainers/pkg/oci
2021-07-06 19:14:10 +08:00