Commit Graph

11307 Commits

Author SHA1 Message Date
Wei Fu
cbebeb9440 pkg/failpoint: add FreeBSD link and update pkg doc
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Wei Fu
3c5e80b63e integration: Add injected failpoint testing for RunPodSandbox
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Wei Fu
be91a219c2 integration: CNI bridge wrapper with failpoint
Introduce cni-bridge-fp as CNI bridge plugin wrapper binary for CRI
testing.

With CNI `io.kubernetes.cri.pod-annotations` capability enabled, the user
can inject the failpoint setting by pod's annotation
`cniFailpointControlStateDir`, which stores each pod's failpoint setting
named by `${K8S_POD_NAMESPACE}-${K8S_POD_NAME}.json`.

When the plugin is invoked, the plugin will check the CNI_ARGS to get
the failpoint for the CNI_COMMAND from disk. For the testing, the user
can prepare setting before RunPodSandbox.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Wei Fu
1ae6e8b076 pkg/failpoint: add DelegatedEval API
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Wei Fu
b297775eaf runtime/v2/shim: return if error in load plugin
If there is any unskipable error during setuping shim plugins, we should
fail return error to prevent from leaky shim instance. For example,
there is error during init task plugin, the shim ttrpc server will not
contain any shim API method. The any call to the shim will receive that

  failed to create shim task: service containerd.task.v2.Task: not implemented

Then containerd can't use `Shutdown` to let the shim close. The shim
will be leaky. And also fail return if there is no ttrpc service.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Wei Fu
5f9b318e50 bin/ctr,integration: new runc-shim with failpoint
Added new runc shim binary in integration testing.

The shim is named by io.containerd.runc-fp.v1, which allows us to use
additional OCI annotation `io.containerd.runtime.v2.shim.failpoint.*` to
setup shim task API's failpoint. Since the shim can be shared with
multiple container, like what kubernetes pod does, the failpoint will be
initialized during setup the shim server. So, the following the
container's OCI failpoint's annotation will not work.

This commit also updates the ctr tool that we can use `--annotation` to
specify annotations when run container. For example:

```bash
➜  ctr run -d --runtime runc-fp.v1 \
     --annotation "io.containerd.runtime.v2.shim.failpoint.Kill=1*error(sorry)" \
     docker.io/library/alpine:latest testing sleep 1d

➜  ctr t ls
TASK       PID       STATUS
testing    147304    RUNNING

➜  ctr t kill -s SIGKILL testing
ctr: sorry: unknown

➜  ctr t kill -s SIGKILL testing

➜  sudo ctr t ls
TASK       PID       STATUS
testing    147304    STOPPED
```

The runc-fp.v1 shim is based on core runc.v2. We can use it to inject
failpoint during testing complicated or big transcation API, like
kubernetes PodRunPodsandbox.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Wei Fu
822cc51d84 runtime/v2: manager supports server interceptor
Currently, the runc shimv2 commandline manager doesn't support ttrpc
server's customized option, for example, the ttrpc server interceptor.
This commit is to allow the task plugin can return the
`UnaryServerInterceptor` option to the manager so that the task plugin
can do enhancement before handling the incoming request, like API-level
failpoint control.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Wei Fu
ffd59ba600 pkg/failpoint: init failpoint package
Failpoint is used to control the fail during API call when testing, especially
the API is complicated like CRI-RunPodSandbox. It can help us to test
the unexpected behavior without mock. The control design is based on freebsd
fail(9), but simpler.

REF: https://www.freebsd.org/cgi/man.cgi?query=fail&sektion=9&apropos=0&manpath=FreeBSD%2B10.0-RELEASE

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Fu Wei
05a71fdc28
Merge pull request #7198 from endocrimes/dani/fix-panic 2022-07-22 23:23:45 +08:00
Danielle Lancashire
3125f7e1a0 cri_stats: handle missing cpu stats
Signed-off-by: Danielle Lancashire <dani@builds.terrible.systems>
2022-07-22 12:10:24 +00:00
Fu Wei
badb66113c
Merge pull request #7189 from zouyee/ctx 2022-07-22 11:09:02 +08:00
Mike Brown
f7bba3a751
Merge pull request #7173 from bobbypage/cgroup_e2e
test: Add ability to switch between  cgroupv1 or cgroupv2 for node e2e
2022-07-20 20:46:04 -05:00
Derek McGowan
24aad6dd46
Merge pull request #7182 from HeavenTonight/main
code cleanup
2022-07-20 13:09:10 -07:00
Derek McGowan
1455926416
Merge pull request #7114 from kinvolk/rata/userns-cri
Update k8s.io/cri-api to v0.25.0-alpha2
2022-07-20 13:06:58 -07:00
Derek McGowan
f1eced563e
Merge pull request #7186 from jsturtevant/windows-usage-nano-cores
Refactor usageNanoCores be to used for all OSes
2022-07-20 13:04:56 -07:00
Derek McGowan
0e6e05a0e8
Merge pull request #7191 from mikebrow/add-containerd.env-for-sbsandbox-mode-test
adds support for using env file for systemd boot
2022-07-20 13:04:35 -07:00
Kazuyoshi Kato
0d61fba052
Merge pull request #7185 from AkihiroSuda/testify-1.8.0
go.mod: github.com/stretchr/testify v1.8.0
2022-07-20 11:51:36 -07:00
Mike Brown
7eeec8987f adds support for using env file for systemd boot
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
2022-07-20 12:52:10 -05:00
zounengren
7dc66eee64 using ContextDialer instead
Signed-off-by: zounengren <zouyee1989@gmail.com>
2022-07-20 22:53:42 +08:00
David Porter
6639b2b028 test: Add ability to switch between cgroupv1 or cgroupv2
For k8s e2e node tests, we want to be able to test both cgroupv1 and
cgroupv2 variants. Currently, the latest version of COS (M97) is running
as cgroupv2 and we would like the add the ability to switch to cgroupv1
for running tests on cgroupv1.

To do this, add a new flag, "CGROUP_MODE" which can be set as v1 or v2.
If the current cgroup configuration does not match the desired config,
the cgroup config will be set via `cgroup_helper` COS utility, and the
node will be rebooted.

Signed-off-by: David Porter <porterdavid@google.com>
2022-07-19 17:51:41 -07:00
James Sturtevant
0d6881898e Refactor usageNanoCores be to used for all OSes
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2022-07-19 16:49:08 -07:00
Akihiro Suda
f6bc986dc1
go.mod: github.com/stretchr/testify v1.8.0
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-07-20 08:36:10 +09:00
Derek McGowan
79fcc38b11
Merge pull request #7145 from junnplus/ctr-user
ctr: support --user for run/create
2022-07-19 13:07:37 -07:00
guiyong.ou
628f6ac681 code cleanup
Signed-off-by: guiyong.ou <guiyong.ou@daocloud.io>
2022-07-19 22:46:32 +08:00
Derek McGowan
11ded166c1
Merge pull request #7174 from oradwell/patch-1
docs: Fix sample config.toml syntax
2022-07-18 15:20:18 -07:00
Derek McGowan
e95858f93f
Merge pull request #7163 from thaJeztah/seccomp_support_pku
seccomp: seccomp: add syscalls related to PKU in default policy
2022-07-18 15:19:10 -07:00
Maksym Pavlenko
e69a83f356
Merge pull request #7168 from mxpv/linter
Update and align golangci-lint version
2022-07-18 12:23:06 -07:00
Maksym Pavlenko
8e66388f52
Merge pull request #7169 from mikebrow/test-sbsandbox
adds a comment explaining how to disable experimental sbserver
2022-07-18 12:22:28 -07:00
Derek McGowan
0bbba90480
Merge pull request #7177 from kzys/fix-cirrus
ci: workaround Cirrus CI's INVALID_ARGUMENT
2022-07-18 12:05:14 -07:00
Kazuyoshi Kato
cc30880e84 ci: workaround Cirrus CI's INVALID_ARGUMENT
We are constantly getting the message below from Cirrus CI;

> Machine type with name 'c2-standard-2' does not exist in zone 'us-central1-c'."

Seems Cirrus CI is constructing the machine type based on
the "cpu" field from the YAML file. However c2-standard's minimal vCPU
count is 4 based on the official document below.

https://cloud.google.com/compute/docs/compute-optimized-machines

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-07-18 17:48:25 +00:00
Oliver Radwell
d8d63a7aa3
docs: Fix sample config.toml syntax
Signed-off-by: Oliver Radwell <oliver.radwell@gmail.com>
2022-07-16 21:56:07 +01:00
Mike Brown
88bcbb0361 adds a comment explaining how to disable experimental sbserver
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
2022-07-15 17:00:56 -05:00
Maksym Pavlenko
3a3f43f72f Fix linter warnings
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-07-15 13:29:04 -07:00
Maksym Pavlenko
60f51c1aa3 Update and align golangci-lint version
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-07-15 13:22:06 -07:00
Fu Wei
e4fefea554
Merge pull request #7153 from mxpv/install-protobuf 2022-07-15 15:44:29 +08:00
Fu Wei
c0f0627319
Merge pull request #7164 from mxpv/cri-fork 2022-07-15 15:19:28 +08:00
Maksym Pavlenko
98a1b7ff1b Add log messages when choosing CRI server
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-07-14 09:12:35 -07:00
Phil Estes
470ebf4499
Merge pull request #7167 from thaJeztah/seccomp_sys_nice
seccomp: add get_mempolicy, mbind, set_mempolicy, with CAP_SYS_NICE
2022-07-14 11:54:19 -04:00
Sebastiaan van Stijn
bbb8d34704
seccomp: add get_mempolicy, mbind, set_mempolicy, with CAP_SYS_NICE
This aligns the profile with docker's profile, which added this in
47dfff68e4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-14 10:39:55 +02:00
Samuel Karp
bb6278749e
Merge pull request #7158 from bart0sh/PR003-fix-cdi-doc-formatting 2022-07-13 23:17:23 -07:00
Fu Wei
b3eb85a344
Merge pull request #7159 from thaJeztah/bump_go_1.18.4 2022-07-14 09:48:39 +08:00
Sebastiaan van Stijn
19e8479837
seccomp: seccomp: add syscalls related to PKU in default policy
Add pkey_alloc(2), pkey_free(2) and pkey_mprotect(2) in seccomp default profile.
pkey_alloc(2), pkey_free(2) and pkey_mprotect(2) can only configure
the calling process's own memory, so they are existing "safe for everyone" syscalls.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-13 23:03:35 +02:00
Maksym Pavlenko
2ba6353316 Change metrics namespace for sandboxed CRI to prevent panic
panic: duplicate metrics collector registration attempted

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-07-13 12:47:13 -07:00
Maksym Pavlenko
b8e93774c1 Enable integration tests against sandboxed CRI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-07-13 12:02:06 -07:00
Maksym Pavlenko
cf5df7e4ac Fork CRI server package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-07-13 10:54:59 -07:00
Sebastiaan van Stijn
4ffef752d0
update golang to 1.18.4, 1.17.12
go1.18.4 (released 2022-07-12) includes security fixes to the compress/gzip,
encoding/gob, encoding/xml, go/parser, io/fs, net/http, and path/filepath
packages, as well as bug fixes to the compiler, the go command, the linker,
the runtime, and the runtime/metrics package. See the Go 1.18.4 milestone on the
issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.18.4+label%3ACherryPickApproved

This update addresses:

CVE-2022-1705, CVE-2022-1962, CVE-2022-28131, CVE-2022-30630, CVE-2022-30631,
CVE-2022-30632, CVE-2022-30633, CVE-2022-30635, and CVE-2022-32148.

Full diff: https://github.com/golang/go/compare/go1.18.3...go1.18.4

From the security announcement;
https://groups.google.com/g/golang-announce/c/nqrv9fbR0zE

We have just released Go versions 1.18.4 and 1.17.12, minor point releases. These
minor releases include 9 security fixes following the security policy:

- net/http: improper sanitization of Transfer-Encoding header

  The HTTP/1 client accepted some invalid Transfer-Encoding headers as indicating
  a "chunked" encoding. This could potentially allow for request smuggling, but
  only if combined with an intermediate server that also improperly failed to
  reject the header as invalid.

  This is CVE-2022-1705 and https://go.dev/issue/53188.

- When `httputil.ReverseProxy.ServeHTTP` was called with a `Request.Header` map
  containing a nil value for the X-Forwarded-For header, ReverseProxy would set
  the client IP as the value of the X-Forwarded-For header, contrary to its
  documentation. In the more usual case where a Director function set the
  X-Forwarded-For header value to nil, ReverseProxy would leave the header
  unmodified as expected.

  This is https://go.dev/issue/53423 and CVE-2022-32148.

  Thanks to Christian Mehlmauer for reporting this issue.

- compress/gzip: stack exhaustion in Reader.Read

  Calling Reader.Read on an archive containing a large number of concatenated
  0-length compressed files can cause a panic due to stack exhaustion.

  This is CVE-2022-30631 and Go issue https://go.dev/issue/53168.

- encoding/xml: stack exhaustion in Unmarshal

  Calling Unmarshal on a XML document into a Go struct which has a nested field
  that uses the any field tag can cause a panic due to stack exhaustion.

  This is CVE-2022-30633 and Go issue https://go.dev/issue/53611.

- encoding/xml: stack exhaustion in Decoder.Skip

  Calling Decoder.Skip when parsing a deeply nested XML document can cause a
  panic due to stack exhaustion. The Go Security team discovered this issue, and
  it was independently reported by Juho Nurminen of Mattermost.

  This is CVE-2022-28131 and Go issue https://go.dev/issue/53614.

- encoding/gob: stack exhaustion in Decoder.Decode

  Calling Decoder.Decode on a message which contains deeply nested structures
  can cause a panic due to stack exhaustion.

  This is CVE-2022-30635 and Go issue https://go.dev/issue/53615.

- path/filepath: stack exhaustion in Glob

  Calling Glob on a path which contains a large number of path separators can
  cause a panic due to stack exhaustion.

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2022-30632 and Go issue https://go.dev/issue/53416.

- io/fs: stack exhaustion in Glob

  Calling Glob on a path which contains a large number of path separators can
  cause a panic due to stack exhaustion.

  This is CVE-2022-30630 and Go issue https://go.dev/issue/53415.

- go/parser: stack exhaustion in all Parse* functions

  Calling any of the Parse functions on Go source code which contains deeply
  nested types or declarations can cause a panic due to stack exhaustion.

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2022-1962 and Go issue https://go.dev/issue/53616.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-13 11:59:05 +02:00
Ed Bartosh
c733119db7 cri doc: fix formatting for CDI options
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2022-07-13 12:38:58 +03:00
Phil Estes
ff91434af1
Merge pull request #7152 from dcantah/fix-err-comments-cri
Fix out of date comments for CRI store packages
2022-07-12 10:46:49 -04:00
Samuel Karp
efd1ff778b
Merge pull request #7124 from ginglis13/devmapper-docs 2022-07-11 21:58:12 -07:00
Ye Sijun
f77d45e3ba
ctr: support --user for run/create
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-07-12 11:53:03 +08:00