3879 Commits

Author SHA1 Message Date
Bin Liu
dd6da22a11 Merge pull request #1525 from Tim-Zhang/disconnect-get-oom
agent: disconnect rpc get_oom_event when destroy_sandbox.
2021-03-22 15:19:31 +08:00
David Gibson
89e5fa7a2f Merge pull request #1506 from dgibson/bug1505
agent: Update Cargo.lock for earlier dependency change
2021-03-20 11:34:32 +11:00
Chelsea Mafrica
f26db684c8 Merge pull request #1508 from dgibson/bug1507
agent: Fix unused import warning in unit tests
2021-03-19 14:20:00 -07:00
Chelsea Mafrica
3369fc8b4b Merge pull request #1514 from fgiudici/port_cgroup_fix
[forwardport] Fixup systemd cgroup handling
2021-03-19 14:18:03 -07:00
James O. D. Hunt
451b45f9d7 agent: Make use of test consts for error messages
Make use of the `const` values for error messages that were previously
only used for the unit tests. This guarantees consistency.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-19 09:17:31 +00:00
Tim Zhang
8c4d3346d4 agent: disconnect rpc get_oom_event when destroy_sandbox.
Otherwise it would block the shutdown of ttrpc.

Fixes: #1524

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-03-19 16:42:37 +08:00
James O. D. Hunt
34e7d5ed97 agent: Validate CID
Validate the container ID as we cannot / should not rely on the
container manager / runtime to do this.

Fixes: #1520.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-18 11:19:34 +00:00
James O. D. Hunt
b265870997 runtime: Validate CID
Validate the container ID as we cannot rely on the container manager
doing this.

Fixes: #1520.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-18 11:19:32 +00:00
James O. D. Hunt
12e9f7f82c runtime: Add missing test mock function
Added a missing `vcmock.Sandbox.GetHypervisorPid()` function.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-17 10:37:47 +00:00
James O. D. Hunt
ea51c17b64 agent: Allow server address to be specified on kernel command-line
To make debugging and testing easier, allow the ttRPC server address to
be specified via `/proc/cmdline` as `agent.server_addr=`.

Fixes: #1516.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-17 08:22:03 +00:00
Chelsea Mafrica
4bf84b4b2f runtime: Add contexts to calls in unit tests
Modify calls in unit tests to use context since many functions were
updated to accept local context to fix trace span ordering.

Fixes #1355

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2021-03-16 17:39:28 -07:00
Chelsea Mafrica
9e4932a6e2 runtime: use root span for shimv2 tracing
Add rootCtx to service struct in shimv2 to use as parent of spans
created in shimv2 for a more organized trace ouput.

Fixes #1355

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2021-03-16 17:39:28 -07:00
Chelsea Mafrica
6b0dc60dda runtime: Fix ordering of trace spans
A significant number of trace calls did not use a parent context that
would create proper span ordering in trace output. Add local context to
functions for use in trace calls to facilitate proper span ordering.
Additionally, change whether trace function returns context in some
functions in virtcontainers and use existing context rather than
background context in bindMount() so that span exists as a child of a
parent span.

Fixes #1355

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2021-03-16 17:39:28 -07:00
Fabiano Fidêncio
50f317dcff Merge pull request #1463 from egernst/bindmount-infra
runtime: add support for readonly sandbox bindmounts
2021-03-16 11:34:53 +01:00
Julien Ropé
3a77e4eb8c build: remove unused variables from Makefile
Some variable are initialized in the Makefile, but never used.
Removing them to clean up the Makefile.

Fixes: #1003

Signed-off-by: Julien Ropé <jrope@redhat.com>
2021-03-16 08:51:16 +01:00
Eric Ernsteernst
d7cb3df0d2 cgroups: Add systemd detection when creating cgroup manager
Look at the provided cgroup path to determine whether systemd is being
used to manage the cgroups. With this, systemd cgroups are being detected
and created appropriately for the sandbox.

Fixes: #599

Signed-off-by: Eric Ernsteernst <eric@amperecomputing.com>

(forward port of https://github.com/kata-containers/runtime/pull/2817)
Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
2021-03-16 08:27:14 +01:00
Eric Ernsteernst
f659871f55 cgroups: remove unused SystemdCgroup variable and accessor/mutators
Since we are now detecting, no longer to keep this state.

Signed-off-by: Eric Ernsteernst <eric@amperecomputing.com>

(forward port of https://github.com/kata-containers/runtime/pull/2817)
Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
2021-03-16 08:26:15 +01:00
David Gibson
b0e966c3bd agent: Fix unused import warning in unit tests
This unneeded import was accidentally introduced by 81607e34.

fixes #1507

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-03-12 17:25:13 +11:00
David Gibson
d5a9d56e79 agent: Update Cargo.lock for earlier dependency change
Commit 81607e34 updated src/agent/rustjail/Cargo.toml, to remove an
unneeded dependency.  That causes cargo to update src/agent/Cargo.lock
on each build.  However, the change to Cargo.lock wasn't checked in
meaning anyone working on the agent code will get bogus diffs with every
build.  Check in the missing file to fix this.

fixes #1505

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-03-12 16:51:30 +11:00
Fupan Li
62d30ca2b6 Merge pull request #1498 from liubin/fix/1497-task-exit-pid
runtime: return hypervisor Pid in TaskExit event
2021-03-11 12:58:28 +08:00
Bo Chen
396565fa56 Merge pull request #1489 from jcvenegas/2021-03-03/codecov
agent: makefile: Add codecov target
2021-03-10 11:21:33 -08:00
Eric Ernst
f0d49851db exec: ensure sup groups are added to agent request
Extra groups were not being handled when exec'ing. Ensure
that these are handled.

Before this, running a pod with:
```
 ...snippet...
 securityContext:
   fsGroup: 266
   runAsGroup: 51020
   runAsUser: 264
```

And then exec'ing would not supply the fsGroup:
```
$ kubectl exec -it kata-bb  -- sh -c id
uid=264 gid=51020
```

Fixes: #1500

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2021-03-09 17:17:55 -08:00
bin
b034458960 runtime: return hypervisor Pid in TaskExit event
Other RPC calls return Pid of hypervisor, the TaskExit should
return the same Pid.

Fixes: #1497

Signed-off-by: bin <bin@hyper.sh>
2021-03-09 17:41:44 +08:00
fupan.lfp
81607e348e rustjail: fix the issue of home_dir function
Since the crate dirs::home_dir function depends on the
libc's api: getpwuid_r, but this api function wouldn't
be static linked on glibc, thus we'd better to figure
out an alternative way to get the home dir from /etc/passwd.
For much more info about this glibc's issue, please see:
https://sourceware.org/bugzilla/show_bug.cgi?id=19341.

This commit read and parse the "/etc/passwd" directly and
fetch the corresponding uid's home dir.

Fixes: #675

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2021-03-08 21:51:23 +08:00
Fupan Li
f6630ddd49 Merge pull request #1478 from lifupan/fix_device
rustjail: fix the issue of bind mount device file from guest
2021-03-08 09:55:00 +08:00
Eric Ernst
48ed8f3c4a runtime: add support for readonly sandbox bindmounts
If specified, sandbox_bind_mounts identifies host paths to be
mounted (ro) into the sandboxes shared path. This is only valid
if filesystem sharing is utilized.

The provided path(s) will be bindmounted (ro) into the shared fs directory on
the host, and thus mapped into the guest. If defaults are utilized,
these mounts should be available in the guest at
`/var/run/kata-containers/shared/containers/sandbox-mounts`

These will not be exposed to the container workloads, and are only
added for potential guest-services to consume (example: expose certs
into the guest that are available on the host).

Fixes: #1464

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2021-03-04 10:04:25 -08:00
Carlos Venegas
7ae349c511 agent: makefile: Add codecov target
Add target to run codecov report locally.

Useful to identify what are the missing lines
to be covered by unit test.

Fixes: #1487

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-04 16:32:52 +00:00
Eric Ernst
6e1ef809e1 Merge pull request #1480 from wainersm/fix_shim_log
runtime: Fix missing 'name' field on containerd-shim-v2 logs
2021-03-02 11:46:09 -08:00
Wainer dos Santos Moschetta
21bdaaf84f runtime: Fix missing 'name' field on containerd-shim-v2 logs
Each Kata Containers application should generate log records with a specified
structure. Currently on containerd-shim-v2's logs, the required 'name' field
is missing. This changed its logger to append the application name on each
and every emitted entries.

Fixes #1479
Related-to: github.com/kata-containers/tests/issues/3260
Suggested-by: James O. D. Hunt <james.o.hunt@intel.com>
Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2021-03-01 16:52:24 -05:00
Eric Ernst
90a18e228b Merge pull request #1457 from mxpv/shared
agent: don't error of virtiofs share is already mounted
2021-03-01 11:16:18 -08:00
fupan.lfp
34dc861cde rustjail: fix the issue of bind mount device file from guest
When do pass guest device files to container, the source
file wouldn't be a regular file, but we also need to create
a corresponding destination file to bind mount source file
to it. Thus it's better to check whether the source file
was a directory instead of regular file.

Fixes: #1477

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2021-03-01 21:20:01 +08:00
Bin Liu
61f0291d63 Merge pull request #1452 from lifupan/main
shimv2: return the hypervisor's pid as the container pid
2021-03-01 15:48:01 +08:00
Eric Ernst
ddb283dd43 Merge pull request #1475 from egernst/yiiiiikes
runtime: check if error loading runtime config
2021-02-26 15:01:22 -08:00
Eric Ernst
0f7098339b runtime: check if error loading runtime config
Looks like we inadvertantly removed the check on the loadRuntimeConfig
error return value. Adding back...

Fixes: #1474

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2021-02-26 10:51:38 -08:00
Bin Liu
7587d2a8d6 Merge pull request #1462 from Tim-Zhang/fix-clippy-for-rust1.5
agent: fix clippy for rustc 1.5
2021-02-26 15:52:03 +08:00
Fupan Li
b5282fa224 Merge pull request #1305 from Tim-Zhang/upgrade-tokio-to-1.0
agent: Upgrade tokio to 1.2.0
2021-02-26 13:33:24 +08:00
Tim Zhang
6f720761ed agent: fix clippy for rustc 1.5
Fixes: #1461

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-25 17:04:54 +08:00
Bin Liu
735fe3f94a Merge pull request #1444 from ManaSugi/fix-blkio-weight
rustjail: fix blkio conversion
2021-02-25 15:20:20 +08:00
Tim Zhang
4a214720e8 agent: Fix test
Struct TtrpcContext has been changed in ttrpc@0.5

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-25 14:38:38 +08:00
Tim Zhang
02079dbb4f agent: upgrade tokio to 1.0
Fixes: #1257

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-25 14:38:32 +08:00
Eric Ernst
2f591f5642 Merge pull request #1459 from mxpv/pid
agent: Agent invokes OCI hooks with wrong PID
2021-02-24 20:08:56 -08:00
Maksym Pavlenko
a42dc74898 agent: Agent invokes OCI hooks with wrong PID
Agent sends -1 PID when invoking OCI hooks.

OCI state struct is initialized before obtaining PID, so this PR moves
`oci_state` call down, right after we get the id.

Fixes: #1458

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-02-24 18:16:17 -08:00
Fupan Li
91ad176a06 Merge pull request #1434 from fidencio/wip/kata-deploy-cleanups
kata-deploy: stop mentioning qemu-virtiofsd, as the default qemu supports virtiofsd already (plus some cleanups)
2021-02-25 09:50:10 +08:00
Maksym Pavlenko
17e9a2cff5 agent: don't error of virtiofs share is already mounted
Port kata-containers/agent#883 to the Rust Agent.

In the event that the virtiofs device is already mounted at the
requested destination, don't error out. We'll check before attempting to
mount to see if the destination is already a mount point. If so, skip
doing the mount in the agent.

This facilitates mounting the sharedfs automatically in the guest before
the agent service starts.

Signed-off-by: Eric Ernst eric.g.ernst@gmail.com

Fixes: #1398

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-02-24 17:05:59 -08:00
Tim Zhang
947913f6e5 agent/protocols: Remove cargo:rerun-if-changed in build.rs
So that the build.rs will be re-runed if any file
within the package is changed.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-02-24 21:50:47 +08:00
fupan.lfp
bc0ac526a2 shimv2: return the hypervisor's pid as the container pid
Since the kata's hypervisor process is in the network namespace,
which is close to container's process, and some host metrics
such as cadvisor can use this pid to access the network namespace
to get some network metrics. Thus this commit replace the shim's
pid with the hypervisor's pid.

Fixes: #1451

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2021-02-24 13:26:05 +08:00
Fabiano Fidêncio
4e494e34c9 packaging: Remove NEMU mentions
There's no more NEMU, for some time already.  Considering this, let's
just remove any mention to it as part of our project.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-02-23 14:24:54 +01:00
Fabiano Fidêncio
f21c54a985 kata-deploy: QEMU, for 2.x, already includes virtiofs
There's no reason to ship qemu & qemu-virtiofs when the former already
includes vitiofs support (and that's the default for 2.x deployments).

In case we will enable experimental qemu DAX support, we should add a
new target, a "qemu-experimental" target, as Carlos has been working on.

Fixes: #1424

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-02-23 14:24:48 +01:00
Manabu Sugimoto
dcea08697a rustjail: fix blkio conversion
BFQ weight controller is using the same BFQ weight scheme (i.e 1->1000).
Therefore, there is no need to do the conversion.

More details here: https://github.com/opencontainers/runc/pull/2786

Fixes: #1440

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2021-02-23 00:26:57 +09:00
bin
bc34cbbce5 agent: Stop receive message from Receiver if got None
If the container has exited, the sender in notifier watching OOM events
will be dropped after the loop exited, and recv() from the according
receiver will get None.

This will lead two problems for get_oom_event rpc all from agent:

- return an wrong OOM event.
- continuously return OOM events.

Fixes: #1369

Signed-off-by: bin <bin@hyper.sh>
2021-02-22 21:56:07 +08:00