Commit Graph

4818 Commits

Author SHA1 Message Date
Xiaochen Shen 325a74ddec libcontainer/intelrdt: rm init() from intelrdt.go
Use sync.Once to init Intel RDT when needed for a small speedup to
operations which do not require Intel RDT.

Simplify IntelRdtManager initialization in LinuxFactory.

Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
2020-12-16 23:37:31 +08:00
Akihiro Suda 544048b865 Merge pull request #2689 from kolyshkin/get-cgroup-mounts-all
libct/cgroup/utils: fix GetCgroupMounts(all=true)
2020-12-08 11:48:13 +09:00
Akihiro Suda 4d8d989404 Merge pull request #2668 from kolyshkin/openat2
libcontainer/cgroups/fscommon: add openat2 support
2020-12-07 14:51:17 +09:00
Akihiro Suda b923ff4373 Merge pull request #2701 from kolyshkin/exec-tty
libct/int/execin_tty: help debug a flake
2020-12-05 09:09:34 +09:00
Akihiro Suda 4b055ff583 Merge pull request #2695 from kolyshkin/linter-nits
Misc linter nits
2020-12-04 12:35:06 +09:00
Kir Kolyshkin 1909051b9c libct/int/execin_tty: help debug a flake
This helps to debug https://github.com/opencontainers/runc/issues/2425

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 17:29:54 -08:00
Mrunal Patel 166068a0ff Merge pull request #2691 from kolyshkin/dont-compile-criu
Dockerfile: use binary criu release; update some ci deps
2020-12-03 16:27:52 -08:00
Kir Kolyshkin 8518317c39 Merge pull request #2407 from piowag/2365-blkio-getstat-update
Update blkio GetStats
2020-12-03 15:46:20 -08:00
Kir Kolyshkin 9792929515 libct/intelrdt: fix a staticcheck warning
> libcontainer/intelrdt/monitoring.go:24:2: SA5001: should check returned error before deferring file.Close() (staticcheck)
> 	defer file.Close()
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 6437086ef5 libct/addCriu*Mount: fix gosimple warning
> libcontainer/container_linux.go:768:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple)
> 	if strings.HasPrefix(mountDest, c.config.Rootfs) {
> 	^
> libcontainer/container_linux.go:1150:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple)
> 	if strings.HasPrefix(mountDest, c.config.Rootfs) {
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin d0b5954826 libct/checkCriuFeatures: fix gosimple linter warning
> libcontainer/container_linux.go:683:2: S1021: should merge variable declaration with assignment on next line (gosimple)
> 	var t criurpc.CriuReqType
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 3de5c51454 libct/int: don't hardcode CAP_NET_ADMIN
... use the one from unix instead.

Coincidentally, this fixes this warning from gosimple linter:

> libcontainer/integration/exec_test.go:448:2: S1021: should merge variable declaration with assignment on next line (gosimple)
>	var netAdminBit uint
>	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 3387422bf9 libct/int: fix "simple" linter warnings
This fixes the following warnings:

> libcontainer/integration/exec_test.go:369:18: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	outputStatus := string(stdout.Bytes())
>	                ^
> libcontainer/integration/exec_test.go:422:18: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	outputStatus := string(stdout.Bytes())
>	                ^
> libcontainer/integration/exec_test.go:486:18: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	outputGroups := string(stdout.Bytes())
>	                ^
> libcontainer/integration/execin_test.go:191:18: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	outputGroups := string(stdout.Bytes())
>	                ^
> libcontainer/integration/execin_test.go:474:9: S1030: should use stdout.String() instead of string(stdout.Bytes()) (gosimple)
>	out := string(stdout.Bytes())
>	       ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 11680cd2c7 libct: fix "unused" linter warning
Commit 4415446c32 introduces this function which is never used.
Remove it.

This fixes

> libcontainer/container_linux.go:1813:26: func `(*linuxContainer).deleteState` is unused (unused)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin a99ecc9ea2 libct/cg/utils: silence a linter warning
> libcontainer/cgroups/utils.go:282:4: SA4006: this value of `paths` is never used (staticcheck)
>			paths = make(map[string]string)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 3c9b03fd73 libct/cg/fscommon: log openat2 init failures
In case we get ENOSYS from openat2(2), this is expected, so log that
we're falling back to using securejoin as debug.

Otherwise, log it as a warning (as the error is unexpected, but we're
still good to go).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:19:06 -08:00
Kir Kolyshkin 6bda460000 libcontainer/cgroups/fscommon: add openat2 support
In case openat2 is available, it will be used to guarantee
that we're not accessing anything other than cgroupfs[2] files.

In cases when openat2 is not available, or when cgroup has a
non-standard prefix (not "/sys/fs/cgroup", which might theoretically
be the case on some very old installs and/or very custom systems),
fall back to using securejoin + os.Open like we did before.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:19:06 -08:00
Piotr Wagner 31b0151fc9 move blkio stat gathering to loop
Signed-off-by: Piotr Wagner <piotr.wagner@intel.com>
2020-12-03 08:18:43 -08:00
Piotr Wagner 990a6c57f1 cgroups: update blkio GetStats
Signed-off-by: Piotr Wagner <piotr.wagner@intel.com>
2020-12-03 08:18:43 -08:00
Kir Kolyshkin be56333fff bats: update to 1.2.1
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-02 19:28:40 -08:00
Kir Kolyshkin f15c4cca2c Update umoci to 0.4.6
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-02 19:28:34 -08:00
Kir Kolyshkin 4344bd8f14 Dockerfile: use binary criu release
This "reverts" commit 9ff7b82f9. We use the repo provided and maintained
by the CRIU team instead of compiling it from source.

While at it,

1. Don't install packages that were solely needed to compile CRIU.

2. Combine all apt-related stuff into a single step, so we don't
   download and then remove apt metadata 3 times.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-02 19:27:42 -08:00
Akihiro Suda bd013b6e4d Merge pull request #2698 from cyphar/memfd_create-hardcode-sysnum
nsenter: hard-code memfd_create(2) syscall numbers
2020-12-03 12:01:21 +09:00
Mrunal Patel 56a1f1f70f Merge pull request #2697 from kolyshkin/validate-nits
.github/workflows/validate: nits
2020-12-02 10:20:38 -08:00
Akihiro Suda 351787708a Merge pull request #2679 from thaJeztah/isolate_device
libcontainer: isolate libcontainer/devices
2020-12-02 18:00:38 +09:00
Aleksa Sarai 3aead32ea2 nsenter: hard-code memfd_create(2) syscall numbers
Some libc versions still in use by distributions (such as SLE) do not
define SYS_memfd_create even though the kernel supports the feature.
Since the syscall numbers are fixed, we can just hard-code them if
__NR_memfd_create is not defined.

We only do this for a handful of architectures, since containers aren't
widely supported on every possible Linux architecture.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-12-02 19:56:39 +11:00
Akihiro Suda 2a50985a8a Merge pull request #2694 from kolyshkin/recvtty-nits
recttty: nits
2020-12-02 11:07:39 +09:00
Kir Kolyshkin 5d1b0268dd .github/workflows/validate: nits
1. Use ubuntu-20.04 instead of ubuntu-latest to fix warnings like

> Ubuntu-latest workflows will use Ubuntu-20.04 soon. For more details,
> see https://github.com/actions/virtual-environments/issues/1816

2. Minor formatting fixes, remove redundant name: etc.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-01 17:24:18 -08:00
Kir Kolyshkin 7cd062d7be libct/cgroup/utils: fix GetCgroupMounts(all=true)
The `all` argument was introduced by commit f557996401 specifically
for use by cAdvisor (see [1]), but there were no test cases added,
so it was later broken by 5ee0648bfb which started incrementing
numFound unconditionally.

Fix this (by not checking numFound in case all is true), and add a
simple test case to avoid future regressions.

[1] https://github.com/google/cadvisor/pull/1476

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-01 15:15:30 -08:00
Sebastiaan van Stijn 4fc2de77e9 libcontainer/devices: remove "Device" prefix from types
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-12-01 11:11:23 +01:00
Sebastiaan van Stijn 677baf22d2 libcontainer: isolate libcontainer/devices
Move the Device-related types to libcontainer/devices, so that
the package can be used in isolation. Aliases have been created
in libcontainer/configs for backward compatibility.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-12-01 11:11:21 +01:00
Kir Kolyshkin de80aae4bc recvtty: fix errcheck linter warnings
Fixes the following errcheck linter warnings

> contrib/cmd/recvtty/recvtty.go:115:10: Error return value of `io.Copy` is not checked (errcheck)
> 		io.Copy(os.Stdout, c)
> 		       ^
> contrib/cmd/recvtty/recvtty.go:120:11: Error return value of `io.Copy` is not checked (errcheck)
> 			io.Copy(c, os.Stdin)
> 			       ^
> contrib/cmd/recvtty/recvtty.go:175:11: Error return value of `io.Copy` is not checked (errcheck)
>			io.Copy(devnull, master)
>			       ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-30 19:30:13 -08:00
Kir Kolyshkin 6b41b463b1 recvtty: fix waiting for both goroutines
It looks like we need to wait for the both copy goroutines to finish,
not just the one that happen to finish first.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-30 19:30:13 -08:00
Kir Kolyshkin 4bbfd2e114 recvtty: use ioutil.Discard
Saves us a few lines of code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-30 19:30:13 -08:00
Mrunal Patel 2b92c25130 Merge pull request #2690 from kolyshkin/gh-act-int
ci: add integration / unit tests to github actions
2020-11-30 13:27:39 -08:00
Mrunal Patel 7cfb3dcfa2 Merge pull request #2692 from kolyshkin/test-tty-nits
tests/int/tty.bats: increase timeout
2020-11-29 17:42:11 -08:00
Kir Kolyshkin c1ef0cf62c ci: add integration+unit tests to github actions
This is Ubuntu 20.04 so cgroup v1 testing only :(
The upside is, it's pretty fast (currently all the tests finish
within 5 minutes).

rootless tests take longer time so we run them in parallel
with non-rootless ones. Also, to balance the time, we run
unit tests when rootless is not set. IOW, 'rootless' in job
name means it's only rootless integration tests, and no rootless
means it's unit tests, integration tests with fs driver, and
integration tests with systemd driver.

Note, `script` is used to run integration tests to provide a tty
(which by default is not available on gh actions).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-27 21:35:02 -08:00
Kir Kolyshkin fce8dd4d66 tests/int/tty.bats: increase timeout
Just saw the timeout being hit on CI (Fedora 33 vagrant VM on Travis),
so let's increase it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-27 14:15:32 -08:00
Mrunal Patel 06b737bb15 Merge pull request #2687 from kolyshkin/more-github-actions
More GitHub actions
2020-11-23 21:02:51 -08:00
Akihiro Suda d15ffff5df Merge pull request #2681 from thaJeztah/fix_bats_link
integration: update README to link to bats-core
2020-11-24 02:02:03 +09:00
Akihiro Suda 0b11e29a87 Merge pull request #2684 from thaJeztah/bump_ebpf
vendor: github.com/cilium/ebpf v0.2.0
2020-11-23 03:44:12 +09:00
Akihiro Suda 69d84cb12d Merge pull request #2688 from kolyshkin/criu-3.15
Dockerfile: bump criu to 3.15
2020-11-23 03:42:07 +09:00
Kir Kolyshkin c6ed18542d ci: add shellcheck to github actions
Note that

1. No golang caching is required, since we do not build any go code,
   and it does not look like it make sense to cache a single binary
   we donwload from github.

2. Use a problem matcher, so the PRs will be annotated with
   shellcheck warnings.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-20 10:35:56 -08:00
Kir Kolyshkin 27835a9e5e Makefile: move shellcheck out of validate
This serves two purposes:

1. A developer can now run `make shellcheck` to show  any issues    with
   shell or bats files formatting (this requires a recent version of
   shfmt, which I think is out of scope for Makefile).

2. Exclude shellcheck from travis ci (will be re-added as a GH action
   by the next commit).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-20 10:35:56 -08:00
Kir Kolyshkin 33bda24ac3 ci: move verify-deps from travis to github actions
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-20 10:35:56 -08:00
Kir Kolyshkin c60f23b335 ci: add shfmt to github actions
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-20 10:35:56 -08:00
Kir Kolyshkin 717a73b397 ci: renamed golangci-lint to validate
...so we can add more validation-type jobs.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-20 10:35:56 -08:00
Kir Kolyshkin 06b204e5c2 Makefile: move shfmt out of validate, add -w
This serves two purposes:

1. A developer can now run `make shfmt` to show and fix any issues
   with shell or bats files formatting (this requires a recent version
   of shfmt, which I think is out of scope for Makefile).

2. Exclude shfmt check from travis ci (will be re-added as a GH action
   by the next commit).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-20 10:35:56 -08:00
Kir Kolyshkin 7856c34018 Dockerfile: bump criu to 3.15
Changes: see https://criu.org/Download/criu/3.15

Note in Vagrant.centos7 we use Adrian's repo [1] which already have criu
3.15, and in Vagrant.fedora33 we use stock fedora which also already has
criu 3.15.

[1] https://copr.fedorainfracloud.org/coprs/adrian/criu-el7/packages/

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-11-20 10:35:32 -08:00
Sebastiaan van Stijn ee1bdb80af vendor: github.com/cilium/ebpf v0.2.0
full diff: https://github.com/cilium/ebpf/compare/v0.1.0...v0.2.0

- btf: add go-fuzz targets
- btf: avoid Type copy in FuncProto.walk
- btf: check err in loadSpecFromVmlinux
- btf: handle type name flavours
- CI: test on 5.9 kernel
- cmd/bpf2go: output ELF .o next to the .go file
- link: add AttachSkLookup
- Remove two unused functions
- Support LSM attach
- use buffered I/O to cut down on read syscalls
- Various doc link fixes

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-11-20 13:56:46 +01:00