Commit Graph

26 Commits

Author SHA1 Message Date
Maksym Pavlenko
1ade777c24 Add basic spec and mounts for Darwin
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-01-12 17:00:40 -08:00
yanggang
b10536d64f
Reused errdefs define error
Signed-off-by: yanggang <gang.yang@daocloud.io>
2022-12-27 14:09:40 +08:00
Henry Wang
b8bf504e94 Enable gosec linter for golangci-lint
`gosec` linter is able to identify issues described in #6584

e.g.

$ git revert 54e95e6b88
[gosec dfc8ca1ec] Revert "fix Implicit memory aliasing in for loop"
 2 files changed, 2 deletions(-)

$ make check
+ proto-fmt
+ check
GOGC=75 golangci-lint run
containerstore.go:192:54: G601: Implicit memory aliasing in for loop. (gosec)
		containers = append(containers, containerFromProto(&container))
		                                                   ^
image_store.go:132:42: G601: Implicit memory aliasing in for loop. (gosec)
		images = append(images, imageFromProto(&image))
		                                       ^
make: *** [check] Error 1

I also disabled following two settings which prevent the linter to show a complete list of issues.

* max-issues-per-linter (default 50)
* max-same-issues (default 3)

Furthermore enabling gosec revealed many other issues. For now I blacklisted the ones except G601.

Will create separate tasks to address them one by one moving next.

Signed-off-by: Henry Wang <henwang@amazon.com>
2022-03-14 22:50:54 +00:00
Paul "TBBle" Hampson
39d52118f5 Plumb CRI Devices through to OCI WindowsDevices
There's two mappings of hostpath to IDType and ID in the wild:
- dockershim and dockerd-cri (implicitly via docker) use class/ID
-- The only supported IDType in Docker is 'class'.
-- https://github.com/aarnaud/k8s-directx-device-plugin generates this form
- https://github.com/jterry75/cri (windows_port branch) uses IDType://ID
-- hcsshim's CRI test suite generates this form

`://` is much more easily distinguishable, so I've gone with that one as
the generic separator, with `class/` as a special-case.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2022-03-12 08:16:43 +11:00
Eng Zer Jun
50da673592
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-09-21 09:50:38 +08:00
Fu Wei
ab963e1cc1
Merge pull request #5063 from Iceber/fix-with-dev-shm-size
oci: fix WithDevShmSize
2021-05-06 23:48:04 +08:00
Akihiro Suda
8ba8533bde
pkg/cri/opts.WithoutRunMount -> oci.WithoutRunMount
Move `pkg/cri/opts.WithoutRunMount` function to `oci.WithoutRunMount`
so that it can be used without dependency on CRI.

Also add `oci.WithoutMounts(dests ...string)` for generality.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-04-07 21:25:36 +09:00
Iceber Gu
b592a4c1ec
oci: fix WithDevShmSize
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-03-17 13:43:58 +08:00
Akihiro Suda
51f985cb1f
oci: move cap UT to _linux_test.go
No substantial code change

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-10 17:42:18 +09:00
Akihiro Suda
a2d1a8a865
oci.WithPrivileged: set the current caps, not the known caps
This change is needed for running the latest containerd inside Docker
that is not aware of the recently added caps (BPF, PERFMON, CHECKPOINT_RESTORE).

Without this change, containerd inside Docker fails to run containers with
"apply caps: operation not permitted" error.

See kubernetes-sigs/kind 2058

NOTE: The caller process of this function is now assumed to be as
privileged as possible.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-10 17:14:17 +09:00
Jie Hao Liao
51a6813c06 Split uid and gid user ns remapping in oci
Signed-off-by: Jie Hao Liao <liaojh1998@gmail.com>
2019-12-10 03:07:50 -06:00
fahedouch
afd33bce81 test add tests to spec_opts
Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

test func WithDefaultPathEnv & WithDefaultSpecForPlatform

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

fix nil context

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

[test] TTY information && ProcessCwd

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

fix TestWithTTYSize value

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

test WithUserNamespace sets the uid and gid mappings for the task

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

format test file

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

update TestWithUserNamespace check condition

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

relaunch ci

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>

improve spec_opts_test test coverage

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>
2019-11-22 18:16:36 +01:00
Michael Crosby
20d3fae3db Add Opt for modifying shm size
Closes #3654

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-09-18 10:20:36 -04:00
Yangyang
1c30d4d04c bugfix: override image.Env with process.Env, rather than be contrary
Signed-off-by: Yangyang <1032120121@163.com>
2019-08-16 18:53:07 +08:00
Lantao Liu
808b223536 Fix race and panic.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-03-28 01:27:13 -07:00
Michael Crosby
bdd84abf05 Add additional capability handling opts
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-03-15 12:31:41 -04:00
akolomentsev
1be86af108 add test for WithImageConfigArgs
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
2018-12-20 18:15:24 -08:00
akolomentsev
f2344db40a do not mutate defaults in replaceOrAppendEnvValues
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
2018-12-19 16:38:22 -08:00
Justin Terry (VM)
7ac221e8d7 Adding ctr memory and cpu flags
Adds ctr run --memory-limit for all platforms.
Adds ctr run --cpu-count for Windows platforms.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-12-10 13:31:59 -08:00
Yongxin Li
03b1dae195 typo fix
Signed-off-by: Yongxin Li <yxli@alauda.io>
2018-09-20 10:56:42 +08:00
Yongxin Li
bd902372de typo fix oci/typo_spec_opts_test
Signed-off-by: Yongxin Li <yxli@alauda.io>
2018-09-18 10:33:23 +08:00
Justin Terry (VM)
c818a6b13d Merges the oci package for Linux and Windows
On Windows we need to be able to create both Linux and Windows OCI spec
files by default to support WCOW and LCOW scenarios. This merges the
compile time differences into runtime differences between the two based
on the spec and platform the user sets.

It maintains the old behavior with Default specs resulting in the
platform default the binary is compiled for.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-30 09:46:04 -07:00
Stephen Day
2a1bd7414b
oci: introduce WithSpecFromFile combinator
We introduce a WithSpecFromFile option combinator to allow creation
simpler creation of OCI specs from a file name. Often used as the first
option in a `SpecOpts` slice, it simplifies choosing between a local
file and the built-in default.

The code in `ctr run` has been updated to use the new option, with out
changing the order of operations or functionality present there.

Signed-off-by: Stephen Day <stephen.day@getcruise.com>
2018-07-27 14:25:42 -07:00
Michael Crosby
62e22a9fe7 Type alias spec in oci package
This allows Go to build third party packages correctly without vendoring
issues what want to create their own SpecOpts.

Fixes #2289

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-17 09:18:46 -04:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Paul Knopf
b4c3cd7640
Add WithEnv and WithMount oci options
Signed-off-by: Paul Knopf <pauldotknopf@gmail.com>
2018-01-22 16:35:31 -05:00