mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Update shim to build using bazel.
The go.mod dependency tree for the shim was somehow contradictory. After resolving these issues (e.g. explicitly imported k8s 1.14, pulling a specific dbus version), and adding all dependencies, the shim can now be build as part of the regular bazel tree. As part of this process, minor cleanup was done in all the source files: headers were standardized (and include "The gVisor Authors" in addition to the "The containerd Authors" if originally derived from containerd sources), and comments were cleaned up to meet coding standards. This change makes the containerd installation dynamic, so that multiple versions can be tested, and drops the static installer for the VM image itself. This change also updates test/root/crictl_test.go and related utilities, so that the containerd tests can be run on any version (and in cases where it applies, they can be run on both v1 and v2 as parameterized tests).
This commit is contained in:
@@ -69,7 +69,10 @@ go_path(
|
||||
name = "gopath",
|
||||
mode = "link",
|
||||
deps = [
|
||||
# Main binary.
|
||||
"//runsc",
|
||||
"//shim/v1:gvisor-containerd-shim",
|
||||
"//shim/v2:containerd-shim-runsc-v1",
|
||||
|
||||
# Packages that are not dependencies of //runsc.
|
||||
"//pkg/sentry/kernel/memevent",
|
||||
|
||||
@@ -121,6 +121,22 @@ tests: ## Runs all local ptrace system call tests.
|
||||
@$(MAKE) test OPTIONS="--test_tag_filters runsc_ptrace test/syscalls/..."
|
||||
.PHONY: tests
|
||||
|
||||
containerd-test-%: ## Runs a local containerd test.
|
||||
containerd-test-%: load-basic_alpine load-basic_python load-basic_busybox load-basic_resolv load-basic_httpd
|
||||
containerd-test-%: install-test-runtime
|
||||
@CONTAINERD_VERSION=$* $(MAKE) sudo TARGETS="tools/installers:containerd"
|
||||
@$(MAKE) sudo TARGETS="test/root:root_test" ARGS="-test.v"
|
||||
|
||||
# Note that we can't run containerd-test-1.1.8 tests here.
|
||||
#
|
||||
# Containerd 1.1.8 should work, but because of a bug in loading images locally
|
||||
# (https://github.com/kubernetes-sigs/cri-tools/issues/421), we are unable to
|
||||
# actually drive the tests. The v1 API is tested exclusively through 1.2.13.
|
||||
containerd-tests: ## Runs all supported containerd version tests.
|
||||
containerd-tests: containerd-test-1.2.13
|
||||
containerd-tests: containerd-test-1.3.4
|
||||
containerd-tests: containerd-test-1.4.0-beta.0
|
||||
|
||||
##
|
||||
## Website & documentation helpers.
|
||||
##
|
||||
@@ -233,11 +249,14 @@ dev: ## Installs a set of local runtimes. Requires sudo.
|
||||
|
||||
refresh: ## Refreshes the runtime binary (for development only). Must have called 'dev' or 'test-install' first.
|
||||
@mkdir -p "$(RUNTIME_DIR)"
|
||||
@$(MAKE) copy TARGETS=runsc DESTINATION="$(RUNTIME_BIN)" && chmod 0755 "$(RUNTIME_BIN)"
|
||||
@$(MAKE) copy TARGETS=runsc DESTINATION="$(RUNTIME_BIN)"
|
||||
@$(MAKE) copy TARGETS=shim/v1:gvisor-containerd-shim DESTINATION="$(RUNTIME_DIR)"
|
||||
@$(MAKE) copy TARGETS=shim/v2:containerd-shim-runsc-v1 DESTINATION="$(RUNTIME_DIR)"
|
||||
.PHONY: install
|
||||
|
||||
test-install: ## Installs the runtime for testing. Requires sudo.
|
||||
install-test-runtime: ## Installs the runtime for testing. Requires sudo.
|
||||
@$(MAKE) refresh ARGS="--net-raw --TESTONLY-test-name-env=RUNSC_TEST_NAME --debug --strace --log-packets $(ARGS)"
|
||||
@$(MAKE) configure RUNTIME=runsc
|
||||
@$(MAKE) configure
|
||||
@sudo systemctl restart docker
|
||||
.PHONY: install-test
|
||||
|
||||
@@ -68,3 +68,12 @@ doc(
|
||||
permalink = "/docs/user_guide/platforms/",
|
||||
weight = "30",
|
||||
)
|
||||
|
||||
doc(
|
||||
name = "runtimeclass",
|
||||
src = "runtimeclass.md",
|
||||
category = "User Guide",
|
||||
permalink = "/docs/user_guide/runtimeclass/",
|
||||
subcategory = "Advanced",
|
||||
weight = "91",
|
||||
)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# RuntimeClass
|
||||
|
||||
First, follow the appropriate installation instructions for your version of
|
||||
containerd.
|
||||
|
||||
* For 1.1 or lower, use `gvisor-containerd-shim`.
|
||||
* For 1.2 or higher, use `containerd-shim-runsc-v1`.
|
||||
|
||||
# Set up the Kubernetes RuntimeClass
|
||||
|
||||
Creating the RuntimeClass in kubernetes is simple once the runtime is available
|
||||
for containerd:
|
||||
|
||||
```shell
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: node.k8s.io/v1beta1
|
||||
kind: RuntimeClass
|
||||
metadata:
|
||||
name: gvisor
|
||||
handler: runsc
|
||||
EOF
|
||||
```
|
||||
|
||||
Pods can now be created using this RuntimeClass:
|
||||
|
||||
```shell
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: nginx-gvisor
|
||||
spec:
|
||||
runtimeClassName: gvisor
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
EOF
|
||||
```
|
||||
|
||||
You can verify that the Pod is running via this RuntimeClass:
|
||||
|
||||
```shell
|
||||
kubectl get pod nginx-gvisor -o wide
|
||||
```
|
||||
@@ -3,18 +3,38 @@ module gvisor.dev/gvisor
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/Microsoft/go-winio v0.4.14 // indirect
|
||||
github.com/Microsoft/hcsshim v0.8.6 // indirect
|
||||
github.com/cenkalti/backoff v0.0.0-20190506075156-2146c9339422
|
||||
github.com/containerd/cgroups v0.0.0-20200520162414-666f4a009ffb
|
||||
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1
|
||||
github.com/containerd/containerd v0.0.0-20190510190154-d0319ec44af6
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02 // indirect
|
||||
github.com/containerd/cri v0.0.0-20190308093238-8a0bd84b9a4c
|
||||
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260
|
||||
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3
|
||||
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7 // indirect
|
||||
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd
|
||||
github.com/gofrs/flock v0.6.1-0.20180915234121-886344bea079
|
||||
github.com/gogo/protobuf v1.3.1
|
||||
github.com/golang/protobuf v1.3.1
|
||||
github.com/google/btree v1.0.0
|
||||
github.com/google/go-cmp v0.3.1 // indirect
|
||||
github.com/google/subcommands v0.0.0-20190508160503-636abe8753b8
|
||||
github.com/kr/pretty v0.2.0 // indirect
|
||||
github.com/kr/pty v1.1.1
|
||||
github.com/opencontainers/runtime-spec v0.1.2-0.20171211145439-b2d941ef6a78
|
||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2 // indirect
|
||||
github.com/opencontainers/runc v1.0.0-rc8 // indirect
|
||||
github.com/opencontainers/runtime-spec v1.0.2
|
||||
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2
|
||||
github.com/vishvananda/netlink v1.0.1-0.20190318003149-adb577d4a45e
|
||||
github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936 // indirect
|
||||
golang.org/x/net v0.0.0-20170716174642-b3756b4b77d7 // indirect
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
|
||||
google.golang.org/genproto v0.0.0-20170523043604-d80a6e20e776 // indirect
|
||||
google.golang.org/grpc v1.12.0
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
gotest.tools v2.2.0+incompatible // indirect
|
||||
)
|
||||
|
||||
@@ -1,32 +1,147 @@
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
|
||||
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/Microsoft/hcsshim v0.8.6 h1:ZfF0+zZeYdzMIVMZHKtDKJvLHj76XCuVae/jNkjj0IA=
|
||||
github.com/Microsoft/hcsshim v0.8.6 h1:ZfF0+zZeYdzMIVMZHKtDKJvLHj76XCuVae/jNkjj0IA=
|
||||
github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
|
||||
github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
|
||||
github.com/cenkalti/backoff v0.0.0-20190506075156-2146c9339422 h1:+FKjzBIdfBHYDvxCv+djmDJdes/AoDtg8gpcxowBlF8=
|
||||
github.com/cenkalti/backoff v0.0.0-20190506075156-2146c9339422/go.mod h1:b6Nc7NRH5C4aCISLry0tLnTjcuTEvoiqcWDdsU0sOGM=
|
||||
github.com/cilium/ebpf v0.0.0-20200110133405-4032b1d8aae3/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg=
|
||||
github.com/containerd/cgroups v0.0.0-20200520162414-666f4a009ffb h1:5/YbYIVboEqSpFSC/iMO9FOIP/q8RIuKfYS2TA1M8WE=
|
||||
github.com/containerd/cgroups v0.0.0-20200520162414-666f4a009ffb/go.mod h1:pA0z1pT8KYB3TCXK/ocprsh7MAkoW8bZVzPdih9snmM=
|
||||
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1 h1:uict5mhHFTzKLUCufdSLym7z/J0CbBJT59lYbP9wtbg=
|
||||
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1 h1:uict5mhHFTzKLUCufdSLym7z/J0CbBJT59lYbP9wtbg=
|
||||
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
|
||||
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
|
||||
github.com/containerd/containerd v0.0.0-20190510190154-d0319ec44af6 h1:BmZa1bGjKctYrIbyjbhZJlGvHceJASpdW5pIDSQcw1E=
|
||||
github.com/containerd/containerd v0.0.0-20190510190154-d0319ec44af6 h1:BmZa1bGjKctYrIbyjbhZJlGvHceJASpdW5pIDSQcw1E=
|
||||
github.com/containerd/containerd v0.0.0-20190510190154-d0319ec44af6/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
|
||||
github.com/containerd/containerd v0.0.0-20190510190154-d0319ec44af6/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02 h1:tN9D97v5A5QuKdcKHKt+UMKrkQ5YXUnD8iM7IAAjEfI=
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/cri v0.0.0-20190308093238-8a0bd84b9a4c h1:+bW7GQb2q32/Liy0ZiR6pkpRXdDHShUXRoWg8OGVWZs=
|
||||
github.com/containerd/cri v0.0.0-20190308093238-8a0bd84b9a4c/go.mod h1:DavH5Qa8+6jOmeOMO3dhWoqksucZDe06LfuhBz/xPZs=
|
||||
github.com/containerd/cri v0.0.0-20190308093238-8a0bd84b9a4c/go.mod h1:DavH5Qa8+6jOmeOMO3dhWoqksucZDe06LfuhBz/xPZs=
|
||||
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260 h1:XGyg7oTtD0DoRFhbpV6x1WfV0flKC4UxXU7ab1zC08U=
|
||||
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260 h1:XGyg7oTtD0DoRFhbpV6x1WfV0flKC4UxXU7ab1zC08U=
|
||||
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
|
||||
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
|
||||
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3 h1:esQOJREg8nw8aXj6uCN5dfW5cKUBiEJ/+nni1Q/D/sw=
|
||||
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3 h1:esQOJREg8nw8aXj6uCN5dfW5cKUBiEJ/+nni1Q/D/sw=
|
||||
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0=
|
||||
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0=
|
||||
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7 h1:SKDlsIhYxNE1LO0xwuOR+3QWj3zRibVQu5jWIMQmOfU=
|
||||
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7 h1:SKDlsIhYxNE1LO0xwuOR+3QWj3zRibVQu5jWIMQmOfU=
|
||||
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
|
||||
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
|
||||
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd h1:JNn81o/xG+8NEo3bC/vx9pbi/g2WI8mtP2/nXzu297Y=
|
||||
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd h1:JNn81o/xG+8NEo3bC/vx9pbi/g2WI8mtP2/nXzu297Y=
|
||||
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
|
||||
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
|
||||
github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28=
|
||||
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gofrs/flock v0.6.1-0.20180915234121-886344bea079 h1:JFTFz3HZTGmgMz4E1TabNBNJljROSYgja1b4l50FNVs=
|
||||
github.com/gofrs/flock v0.6.1-0.20180915234121-886344bea079/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
|
||||
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
|
||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/subcommands v0.0.0-20190508160503-636abe8753b8 h1:GZGUPQiZfYrd9uOqyqwbQcHPkz/EZJVkZB1MkaO9UBI=
|
||||
github.com/google/subcommands v0.0.0-20190508160503-636abe8753b8/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/opencontainers/runtime-spec v0.1.2-0.20171211145439-b2d941ef6a78 h1:d9F+LNYwMyi3BDN4GzZdaSiq4otb8duVEWyZjeUtOQI=
|
||||
github.com/opencontainers/runtime-spec v0.1.2-0.20171211145439-b2d941ef6a78/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2 h1:QhPf3A2AZW3tTGvHPg0TA+CR3oHbVLlXUhlghqISp1I=
|
||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
github.com/opencontainers/runc v1.0.0-rc8 h1:dDCFes8Hj1r/i5qnypONo5jdOme/8HWZC/aNDyhECt0=
|
||||
github.com/opencontainers/runc v1.0.0-rc8/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
github.com/opencontainers/runc v1.0.0-rc8/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0=
|
||||
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 h1:b6uOv7YOFK0TYG7HtkIgExQo+2RdLuwRft63jn2HWj8=
|
||||
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/vishvananda/netlink v1.0.1-0.20190318003149-adb577d4a45e h1:/Tdc23Arz1OtdIsBY2utWepGRQ9fEAJlhkdoLzWMK8Q=
|
||||
github.com/vishvananda/netlink v1.0.1-0.20190318003149-adb577d4a45e/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
|
||||
github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936 h1:J9gO8RJCAFlln1jsvRba/CWVUnMHwObklfxxjErl1uk=
|
||||
github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/net v0.0.0-20170716174642-b3756b4b77d7 h1:FCqk7JXVeupwwnGVopQCC0a0xRK0Rj7SL5AyjjWo4pk=
|
||||
golang.org/x/net v0.0.0-20170716174642-b3756b4b77d7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20170716174642-b3756b4b77d7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b h1:ag/x1USPSsqHud38I9BAC88qdNLDHHtQ4mlgQIZPPNA=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
google.golang.org/genproto v0.0.0-20170523043604-d80a6e20e776 h1:wVJP1pATLVPNxCz4R2mTO6HUJgfGE0PmIu2E10RuhCw=
|
||||
google.golang.org/genproto v0.0.0-20170523043604-d80a6e20e776/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20170523043604-d80a6e20e776/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/grpc v1.12.0 h1:Mm8atZtkT+P6R43n/dqNDWkPPu5BwRVu/1rJnJCeZH8=
|
||||
google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
load("//tools:defs.bzl", "go_library")
|
||||
|
||||
package(licenses = ["notice"])
|
||||
|
||||
go_library(
|
||||
name = "runsc",
|
||||
srcs = [
|
||||
"runsc.go",
|
||||
"utils.go",
|
||||
],
|
||||
visibility = ["//:sandbox"],
|
||||
deps = [
|
||||
"@com_github_containerd_go_runc//:go_default_library",
|
||||
"@com_github_opencontainers_runtime-spec//specs-go:go_default_library",
|
||||
],
|
||||
)
|
||||
+26
-23
@@ -34,10 +34,10 @@ import (
|
||||
|
||||
var Monitor runc.ProcessMonitor = runc.Monitor
|
||||
|
||||
// DefaultCommand is the default command for Runsc
|
||||
// DefaultCommand is the default command for Runsc.
|
||||
const DefaultCommand = "runsc"
|
||||
|
||||
// Runsc is the client to the runsc cli
|
||||
// Runsc is the client to the runsc cli.
|
||||
type Runsc struct {
|
||||
Command string
|
||||
PdeathSignal syscall.Signal
|
||||
@@ -48,7 +48,7 @@ type Runsc struct {
|
||||
Config map[string]string
|
||||
}
|
||||
|
||||
// List returns all containers created inside the provided runsc root directory
|
||||
// List returns all containers created inside the provided runsc root directory.
|
||||
func (r *Runsc) List(context context.Context) ([]*runc.Container, error) {
|
||||
data, err := cmdOutput(r.command(context, "list", "--format=json"), false)
|
||||
if err != nil {
|
||||
@@ -61,7 +61,7 @@ func (r *Runsc) List(context context.Context) ([]*runc.Container, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// State returns the state for the container provided by id
|
||||
// State returns the state for the container provided by id.
|
||||
func (r *Runsc) State(context context.Context, id string) (*runc.Container, error) {
|
||||
data, err := cmdOutput(r.command(context, "state", id), true)
|
||||
if err != nil {
|
||||
@@ -76,9 +76,11 @@ func (r *Runsc) State(context context.Context, id string) (*runc.Container, erro
|
||||
|
||||
type CreateOpts struct {
|
||||
runc.IO
|
||||
// PidFile is a path to where a pid file should be created
|
||||
PidFile string
|
||||
ConsoleSocket runc.ConsoleSocket
|
||||
|
||||
// PidFile is a path to where a pid file should be created.
|
||||
PidFile string
|
||||
|
||||
// UserLog is a path to where runsc user log should be generated.
|
||||
UserLog string
|
||||
}
|
||||
@@ -100,7 +102,7 @@ func (o *CreateOpts) args() (out []string, err error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Create creates a new container and returns its pid if it was created successfully
|
||||
// Create creates a new container and returns its pid if it was created successfully.
|
||||
func (r *Runsc) Create(context context.Context, id, bundle string, opts *CreateOpts) error {
|
||||
args := []string{"create", "--bundle", bundle}
|
||||
if opts != nil {
|
||||
@@ -141,7 +143,7 @@ func (r *Runsc) Create(context context.Context, id, bundle string, opts *CreateO
|
||||
return err
|
||||
}
|
||||
|
||||
// Start will start an already created container
|
||||
// Start will start an already created container.
|
||||
func (r *Runsc) Start(context context.Context, id string, cio runc.IO) error {
|
||||
cmd := r.command(context, "start", id)
|
||||
if cio != nil {
|
||||
@@ -181,6 +183,7 @@ type waitResult struct {
|
||||
}
|
||||
|
||||
// Wait will wait for a running container, and return its exit status.
|
||||
//
|
||||
// TODO(random-liu): Add exec process support.
|
||||
func (r *Runsc) Wait(context context.Context, id string) (int, error) {
|
||||
data, err := cmdOutput(r.command(context, "wait", id), true)
|
||||
@@ -226,8 +229,8 @@ func (o *ExecOpts) args() (out []string, err error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Exec executres and additional process inside the container based on a full
|
||||
// OCI Process specification
|
||||
// Exec executes an additional process inside the container based on a full OCI
|
||||
// Process specification.
|
||||
func (r *Runsc) Exec(context context.Context, id string, spec specs.Process, opts *ExecOpts) error {
|
||||
f, err := ioutil.TempFile(os.Getenv("XDG_RUNTIME_DIR"), "runsc-process")
|
||||
if err != nil {
|
||||
@@ -276,8 +279,8 @@ func (r *Runsc) Exec(context context.Context, id string, spec specs.Process, opt
|
||||
return err
|
||||
}
|
||||
|
||||
// Run runs the create, start, delete lifecycle of the container
|
||||
// and returns its exit status after it has exited
|
||||
// Run runs the create, start, delete lifecycle of the container and returns
|
||||
// its exit status after it has exited.
|
||||
func (r *Runsc) Run(context context.Context, id, bundle string, opts *CreateOpts) (int, error) {
|
||||
args := []string{"run", "--bundle", bundle}
|
||||
if opts != nil {
|
||||
@@ -309,7 +312,7 @@ func (o *DeleteOpts) args() (out []string) {
|
||||
return out
|
||||
}
|
||||
|
||||
// Delete deletes the container
|
||||
// Delete deletes the container.
|
||||
func (r *Runsc) Delete(context context.Context, id string, opts *DeleteOpts) error {
|
||||
args := []string{"delete"}
|
||||
if opts != nil {
|
||||
@@ -318,7 +321,7 @@ func (r *Runsc) Delete(context context.Context, id string, opts *DeleteOpts) err
|
||||
return r.runOrError(r.command(context, append(args, id)...))
|
||||
}
|
||||
|
||||
// KillOpts specifies options for killing a container and its processes
|
||||
// KillOpts specifies options for killing a container and its processes.
|
||||
type KillOpts struct {
|
||||
All bool
|
||||
Pid int
|
||||
@@ -334,7 +337,7 @@ func (o *KillOpts) args() (out []string) {
|
||||
return out
|
||||
}
|
||||
|
||||
// Kill sends the specified signal to the container
|
||||
// Kill sends the specified signal to the container.
|
||||
func (r *Runsc) Kill(context context.Context, id string, sig int, opts *KillOpts) error {
|
||||
args := []string{
|
||||
"kill",
|
||||
@@ -345,7 +348,7 @@ func (r *Runsc) Kill(context context.Context, id string, sig int, opts *KillOpts
|
||||
return r.runOrError(r.command(context, append(args, id, strconv.Itoa(sig))...))
|
||||
}
|
||||
|
||||
// Stats return the stats for a container like cpu, memory, and io
|
||||
// Stats return the stats for a container like cpu, memory, and I/O.
|
||||
func (r *Runsc) Stats(context context.Context, id string) (*runc.Stats, error) {
|
||||
cmd := r.command(context, "events", "--stats", id)
|
||||
rd, err := cmd.StdoutPipe()
|
||||
@@ -367,7 +370,7 @@ func (r *Runsc) Stats(context context.Context, id string) (*runc.Stats, error) {
|
||||
return e.Stats, nil
|
||||
}
|
||||
|
||||
// Events returns an event stream from runsc for a container with stats and OOM notifications
|
||||
// Events returns an event stream from runsc for a container with stats and OOM notifications.
|
||||
func (r *Runsc) Events(context context.Context, id string, interval time.Duration) (chan *runc.Event, error) {
|
||||
cmd := r.command(context, "events", fmt.Sprintf("--interval=%ds", int(interval.Seconds())), id)
|
||||
rd, err := cmd.StdoutPipe()
|
||||
@@ -406,7 +409,7 @@ func (r *Runsc) Events(context context.Context, id string, interval time.Duratio
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Ps lists all the processes inside the container returning their pids
|
||||
// Ps lists all the processes inside the container returning their pids.
|
||||
func (r *Runsc) Ps(context context.Context, id string) ([]int, error) {
|
||||
data, err := cmdOutput(r.command(context, "ps", "--format", "json", id), true)
|
||||
if err != nil {
|
||||
@@ -419,7 +422,7 @@ func (r *Runsc) Ps(context context.Context, id string) ([]int, error) {
|
||||
return pids, nil
|
||||
}
|
||||
|
||||
// Top lists all the processes inside the container returning the full ps data
|
||||
// Top lists all the processes inside the container returning the full ps data.
|
||||
func (r *Runsc) Top(context context.Context, id string) (*runc.TopResults, error) {
|
||||
data, err := cmdOutput(r.command(context, "ps", "--format", "table", id), true)
|
||||
if err != nil {
|
||||
@@ -450,10 +453,10 @@ func (r *Runsc) args() []string {
|
||||
return args
|
||||
}
|
||||
|
||||
// runOrError will run the provided command. If an error is
|
||||
// encountered and neither Stdout or Stderr was set the error and the
|
||||
// stderr of the command will be returned in the format of <error>:
|
||||
// <stderr>
|
||||
// runOrError will run the provided command.
|
||||
//
|
||||
// If an error is encountered and neither Stdout or Stderr was set the error
|
||||
// will be returned in the format of <error>: <stderr>.
|
||||
func (r *Runsc) runOrError(cmd *exec.Cmd) error {
|
||||
if cmd.Stdout != nil || cmd.Stderr != nil {
|
||||
ec, err := Monitor.Start(cmd)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
load("//tools:defs.bzl", "go_library")
|
||||
|
||||
package(licenses = ["notice"])
|
||||
|
||||
go_library(
|
||||
name = "proc",
|
||||
srcs = [
|
||||
"deleted_state.go",
|
||||
"exec.go",
|
||||
"exec_state.go",
|
||||
"init.go",
|
||||
"init_state.go",
|
||||
"io.go",
|
||||
"process.go",
|
||||
"types.go",
|
||||
"utils.go",
|
||||
],
|
||||
visibility = [
|
||||
"//pkg/shim:__subpackages__",
|
||||
"//shim:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//pkg/shim/runsc",
|
||||
"@com_github_containerd_console//:go_default_library",
|
||||
"@com_github_containerd_containerd//errdefs:go_default_library",
|
||||
"@com_github_containerd_containerd//log:go_default_library",
|
||||
"@com_github_containerd_containerd//mount:go_default_library",
|
||||
"@com_github_containerd_containerd//runtime/proc:go_default_library",
|
||||
"@com_github_containerd_fifo//:go_default_library",
|
||||
"@com_github_containerd_go_runc//:go_default_library",
|
||||
"@com_github_gogo_protobuf//types:go_default_library",
|
||||
"@com_github_opencontainers_runtime-spec//specs-go:go_default_library",
|
||||
"@org_golang_x_sys//unix:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -17,33 +17,33 @@ package proc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/runtime/proc"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type deletedState struct{}
|
||||
|
||||
func (*deletedState) Resize(ws console.WinSize) error {
|
||||
return errors.Errorf("cannot resize a deleted process")
|
||||
return fmt.Errorf("cannot resize a deleted process")
|
||||
}
|
||||
|
||||
func (*deletedState) Start(ctx context.Context) error {
|
||||
return errors.Errorf("cannot start a deleted process")
|
||||
return fmt.Errorf("cannot start a deleted process")
|
||||
}
|
||||
|
||||
func (*deletedState) Delete(ctx context.Context) error {
|
||||
return errors.Wrap(errdefs.ErrNotFound, "cannot delete a deleted process")
|
||||
return fmt.Errorf("cannot delete a deleted process: %w", errdefs.ErrNotFound)
|
||||
}
|
||||
|
||||
func (*deletedState) Kill(ctx context.Context, sig uint32, all bool) error {
|
||||
return errors.Wrap(errdefs.ErrNotFound, "cannot kill a deleted process")
|
||||
return fmt.Errorf("cannot kill a deleted process: %w", errdefs.ErrNotFound)
|
||||
}
|
||||
|
||||
func (*deletedState) SetExited(status int) {}
|
||||
|
||||
func (*deletedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
|
||||
return nil, errors.Errorf("cannot exec in a deleted state")
|
||||
return nil, fmt.Errorf("cannot exec in a deleted state")
|
||||
}
|
||||
|
||||
+13
-12
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/containerd/fifo"
|
||||
runc "github.com/containerd/go-runc"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/shim/runsc"
|
||||
@@ -151,9 +150,11 @@ func (e *execProcess) kill(ctx context.Context, sig uint32, _ bool) error {
|
||||
if err := e.parent.runtime.Kill(ctx, e.parent.id, int(sig), &runsc.KillOpts{
|
||||
Pid: internalPid,
|
||||
}); err != nil {
|
||||
// If this returns error, consider the process has already stopped.
|
||||
// If this returns error, consider the process has
|
||||
// already stopped.
|
||||
//
|
||||
// TODO: Fix after signal handling is fixed.
|
||||
return errors.Wrapf(errdefs.ErrNotFound, err.Error())
|
||||
return fmt.Errorf("%s: %w", err.Error(), errdefs.ErrNotFound)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -182,16 +183,16 @@ func (e *execProcess) start(ctx context.Context) (err error) {
|
||||
)
|
||||
if e.stdio.Terminal {
|
||||
if socket, err = runc.NewTempConsoleSocket(); err != nil {
|
||||
return errors.Wrap(err, "failed to create runc console socket")
|
||||
return fmt.Errorf("failed to create runc console socket: %w", err)
|
||||
}
|
||||
defer socket.Close()
|
||||
} else if e.stdio.IsNull() {
|
||||
if e.io, err = runc.NewNullIO(); err != nil {
|
||||
return errors.Wrap(err, "creating new NULL IO")
|
||||
return fmt.Errorf("creating new NULL IO: %w", err)
|
||||
}
|
||||
} else {
|
||||
if e.io, err = runc.NewPipeIO(e.parent.IoUID, e.parent.IoGID, withConditionalIO(e.stdio)); err != nil {
|
||||
return errors.Wrap(err, "failed to create runc io pipes")
|
||||
return fmt.Errorf("failed to create runc io pipes: %w", err)
|
||||
}
|
||||
}
|
||||
opts := &runsc.ExecOpts{
|
||||
@@ -217,7 +218,7 @@ func (e *execProcess) start(ctx context.Context) (err error) {
|
||||
if e.stdio.Stdin != "" {
|
||||
sc, err := fifo.OpenFifo(context.Background(), e.stdio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to open stdin fifo %s", e.stdio.Stdin)
|
||||
return fmt.Errorf("failed to open stdin fifo %s: %w", e.stdio.Stdin, err)
|
||||
}
|
||||
e.closers = append(e.closers, sc)
|
||||
e.stdin = sc
|
||||
@@ -228,25 +229,25 @@ func (e *execProcess) start(ctx context.Context) (err error) {
|
||||
if socket != nil {
|
||||
console, err := socket.ReceiveMaster()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to retrieve console master")
|
||||
return fmt.Errorf("failed to retrieve console master: %w", err)
|
||||
}
|
||||
if e.console, err = e.parent.Platform.CopyConsole(ctx, console, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, ©WaitGroup); err != nil {
|
||||
return errors.Wrap(err, "failed to start console copy")
|
||||
return fmt.Errorf("failed to start console copy: %w", err)
|
||||
}
|
||||
} else if !e.stdio.IsNull() {
|
||||
if err := copyPipes(ctx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, ©WaitGroup); err != nil {
|
||||
return errors.Wrap(err, "failed to start io pipe copy")
|
||||
return fmt.Errorf("failed to start io pipe copy: %w", err)
|
||||
}
|
||||
}
|
||||
copyWaitGroup.Wait()
|
||||
pid, err := runc.ReadPidFile(opts.PidFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to retrieve OCI runtime exec pid")
|
||||
return fmt.Errorf("failed to retrieve OCI runtime exec pid: %w", err)
|
||||
}
|
||||
e.pid = pid
|
||||
internalPid, err := runc.ReadPidFile(opts.InternalPidFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to retrieve OCI runtime exec internal pid")
|
||||
return fmt.Errorf("failed to retrieve OCI runtime exec internal pid: %w", err)
|
||||
}
|
||||
e.internalPid = internalPid
|
||||
go func() {
|
||||
|
||||
@@ -17,9 +17,9 @@ package proc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type execState interface {
|
||||
@@ -43,7 +43,7 @@ func (s *execCreatedState) transition(name string) error {
|
||||
case "deleted":
|
||||
s.p.execState = &deletedState{}
|
||||
default:
|
||||
return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func (s *execRunningState) transition(name string) error {
|
||||
case "stopped":
|
||||
s.p.execState = &execStoppedState{p: s.p}
|
||||
default:
|
||||
return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -97,11 +97,11 @@ func (s *execRunningState) Resize(ws console.WinSize) error {
|
||||
}
|
||||
|
||||
func (s *execRunningState) Start(ctx context.Context) error {
|
||||
return errors.Errorf("cannot start a running process")
|
||||
return fmt.Errorf("cannot start a running process")
|
||||
}
|
||||
|
||||
func (s *execRunningState) Delete(ctx context.Context) error {
|
||||
return errors.Errorf("cannot delete a running process")
|
||||
return fmt.Errorf("cannot delete a running process")
|
||||
}
|
||||
|
||||
func (s *execRunningState) Kill(ctx context.Context, sig uint32, all bool) error {
|
||||
@@ -125,17 +125,17 @@ func (s *execStoppedState) transition(name string) error {
|
||||
case "deleted":
|
||||
s.p.execState = &deletedState{}
|
||||
default:
|
||||
return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *execStoppedState) Resize(ws console.WinSize) error {
|
||||
return errors.Errorf("cannot resize a stopped container")
|
||||
return fmt.Errorf("cannot resize a stopped container")
|
||||
}
|
||||
|
||||
func (s *execStoppedState) Start(ctx context.Context) error {
|
||||
return errors.Errorf("cannot start a stopped process")
|
||||
return fmt.Errorf("cannot start a stopped process")
|
||||
}
|
||||
|
||||
func (s *execStoppedState) Delete(ctx context.Context) error {
|
||||
|
||||
+40
-40
@@ -18,6 +18,7 @@ package proc
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -33,23 +34,22 @@ import (
|
||||
"github.com/containerd/fifo"
|
||||
runc "github.com/containerd/go-runc"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/shim/runsc"
|
||||
)
|
||||
|
||||
// InitPidFile name of the file that contains the init pid
|
||||
// InitPidFile name of the file that contains the init pid.
|
||||
const InitPidFile = "init.pid"
|
||||
|
||||
// Init represents an initial process for a container
|
||||
// Init represents an initial process for a container.
|
||||
type Init struct {
|
||||
wg sync.WaitGroup
|
||||
initState initState
|
||||
|
||||
// mu is used to ensure that `Start()` and `Exited()` calls return in
|
||||
// the right order when invoked in separate go routines.
|
||||
// This is the case within the shim implementation as it makes use of
|
||||
// the reaper interface.
|
||||
// the right order when invoked in separate go routines. This is the
|
||||
// case within the shim implementation as it makes use of the reaper
|
||||
// interface.
|
||||
mu sync.Mutex
|
||||
|
||||
waitBlock chan struct{}
|
||||
@@ -76,7 +76,7 @@ type Init struct {
|
||||
Monitor ProcessMonitor
|
||||
}
|
||||
|
||||
// NewRunsc returns a new runsc instance for a process
|
||||
// NewRunsc returns a new runsc instance for a process.
|
||||
func NewRunsc(root, path, namespace, runtime string, config map[string]string) *runsc.Runsc {
|
||||
if root == "" {
|
||||
root = RunscRoot
|
||||
@@ -91,7 +91,7 @@ func NewRunsc(root, path, namespace, runtime string, config map[string]string) *
|
||||
}
|
||||
}
|
||||
|
||||
// New returns a new init process
|
||||
// New returns a new init process.
|
||||
func New(id string, runtime *runsc.Runsc, stdio proc.Stdio) *Init {
|
||||
p := &Init{
|
||||
id: id,
|
||||
@@ -104,21 +104,21 @@ func New(id string, runtime *runsc.Runsc, stdio proc.Stdio) *Init {
|
||||
return p
|
||||
}
|
||||
|
||||
// Create the process with the provided config
|
||||
// Create the process with the provided config.
|
||||
func (p *Init) Create(ctx context.Context, r *CreateConfig) (err error) {
|
||||
var socket *runc.Socket
|
||||
if r.Terminal {
|
||||
if socket, err = runc.NewTempConsoleSocket(); err != nil {
|
||||
return errors.Wrap(err, "failed to create OCI runtime console socket")
|
||||
return fmt.Errorf("failed to create OCI runtime console socket: %w", err)
|
||||
}
|
||||
defer socket.Close()
|
||||
} else if hasNoIO(r) {
|
||||
if p.io, err = runc.NewNullIO(); err != nil {
|
||||
return errors.Wrap(err, "creating new NULL IO")
|
||||
return fmt.Errorf("creating new NULL IO: %w", err)
|
||||
}
|
||||
} else {
|
||||
if p.io, err = runc.NewPipeIO(p.IoUID, p.IoGID, withConditionalIO(p.stdio)); err != nil {
|
||||
return errors.Wrap(err, "failed to create OCI runtime io pipes")
|
||||
return fmt.Errorf("failed to create OCI runtime io pipes: %w", err)
|
||||
}
|
||||
}
|
||||
pidFile := filepath.Join(p.Bundle, InitPidFile)
|
||||
@@ -139,7 +139,7 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) (err error) {
|
||||
if r.Stdin != "" {
|
||||
sc, err := fifo.OpenFifo(context.Background(), r.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to open stdin fifo %s", r.Stdin)
|
||||
return fmt.Errorf("failed to open stdin fifo %s: %w", r.Stdin, err)
|
||||
}
|
||||
p.stdin = sc
|
||||
p.closers = append(p.closers, sc)
|
||||
@@ -150,58 +150,58 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) (err error) {
|
||||
if socket != nil {
|
||||
console, err := socket.ReceiveMaster()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to retrieve console master")
|
||||
return fmt.Errorf("failed to retrieve console master: %w", err)
|
||||
}
|
||||
console, err = p.Platform.CopyConsole(ctx, console, r.Stdin, r.Stdout, r.Stderr, &p.wg, ©WaitGroup)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to start console copy")
|
||||
return fmt.Errorf("failed to start console copy: %w", err)
|
||||
}
|
||||
p.console = console
|
||||
} else if !hasNoIO(r) {
|
||||
if err := copyPipes(ctx, p.io, r.Stdin, r.Stdout, r.Stderr, &p.wg, ©WaitGroup); err != nil {
|
||||
return errors.Wrap(err, "failed to start io pipe copy")
|
||||
return fmt.Errorf("failed to start io pipe copy: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
copyWaitGroup.Wait()
|
||||
pid, err := runc.ReadPidFile(pidFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to retrieve OCI runtime container pid")
|
||||
return fmt.Errorf("failed to retrieve OCI runtime container pid: %w", err)
|
||||
}
|
||||
p.pid = pid
|
||||
return nil
|
||||
}
|
||||
|
||||
// Wait for the process to exit
|
||||
// Wait waits for the process to exit.
|
||||
func (p *Init) Wait() {
|
||||
<-p.waitBlock
|
||||
}
|
||||
|
||||
// ID of the process
|
||||
// ID returns the ID of the process.
|
||||
func (p *Init) ID() string {
|
||||
return p.id
|
||||
}
|
||||
|
||||
// Pid of the process
|
||||
// Pid returns the PID of the process.
|
||||
func (p *Init) Pid() int {
|
||||
return p.pid
|
||||
}
|
||||
|
||||
// ExitStatus of the process
|
||||
// ExitStatus returns the exit status of the process.
|
||||
func (p *Init) ExitStatus() int {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
return p.status
|
||||
}
|
||||
|
||||
// ExitedAt at time when the process exited
|
||||
// ExitedAt returns the time when the process exited.
|
||||
func (p *Init) ExitedAt() time.Time {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
return p.exited
|
||||
}
|
||||
|
||||
// Status of the process
|
||||
// Status returns the status of the process.
|
||||
func (p *Init) Status(ctx context.Context) (string, error) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -215,7 +215,7 @@ func (p *Init) Status(ctx context.Context) (string, error) {
|
||||
return p.convertStatus(c.Status), nil
|
||||
}
|
||||
|
||||
// Start the init process
|
||||
// Start starts the init process.
|
||||
func (p *Init) Start(ctx context.Context) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -250,7 +250,7 @@ func (p *Init) start(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetExited of the init process with the next status
|
||||
// SetExited set the exit stauts of the init process.
|
||||
func (p *Init) SetExited(status int) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -265,7 +265,7 @@ func (p *Init) setExited(status int) {
|
||||
close(p.waitBlock)
|
||||
}
|
||||
|
||||
// Delete the init process
|
||||
// Delete deletes the init process.
|
||||
func (p *Init) Delete(ctx context.Context) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -298,13 +298,13 @@ func (p *Init) delete(ctx context.Context) error {
|
||||
if err2 := mount.UnmountAll(p.Rootfs, 0); err2 != nil {
|
||||
log.G(ctx).WithError(err2).Warn("failed to cleanup rootfs mount")
|
||||
if err == nil {
|
||||
err = errors.Wrap(err2, "failed rootfs umount")
|
||||
err = fmt.Errorf("failed rootfs umount: %w", err2)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Resize the init processes console
|
||||
// Resize resizes the init processes console.
|
||||
func (p *Init) Resize(ws console.WinSize) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -322,7 +322,7 @@ func (p *Init) resize(ws console.WinSize) error {
|
||||
return p.console.Resize(ws)
|
||||
}
|
||||
|
||||
// Kill the init process
|
||||
// Kill kills the init process.
|
||||
func (p *Init) Kill(ctx context.Context, signal uint32, all bool) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -340,7 +340,7 @@ func (p *Init) kill(context context.Context, signal uint32, all bool) error {
|
||||
c, err := p.runtime.State(context, p.id)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "does not exist") {
|
||||
return errors.Wrapf(errdefs.ErrNotFound, "no such process")
|
||||
return fmt.Errorf("no such process: %w", errdefs.ErrNotFound)
|
||||
}
|
||||
return p.runtimeError(err, "OCI runtime state failed")
|
||||
}
|
||||
@@ -348,7 +348,7 @@ func (p *Init) kill(context context.Context, signal uint32, all bool) error {
|
||||
// If the container is not in running state, directly return
|
||||
// "no such process"
|
||||
if p.convertStatus(c.Status) == "stopped" {
|
||||
return errors.Wrapf(errdefs.ErrNotFound, "no such process")
|
||||
return fmt.Errorf("no such process: %w", errdefs.ErrNotFound)
|
||||
}
|
||||
killErr = p.runtime.Kill(context, p.id, int(signal), &runsc.KillOpts{
|
||||
All: all,
|
||||
@@ -362,7 +362,7 @@ func (p *Init) kill(context context.Context, signal uint32, all bool) error {
|
||||
return p.runtimeError(killErr, "kill timeout")
|
||||
}
|
||||
|
||||
// KillAll processes belonging to the init process
|
||||
// KillAll kills all processes belonging to the init process.
|
||||
func (p *Init) KillAll(context context.Context) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -380,17 +380,17 @@ func (p *Init) killAll(context context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stdin of the process
|
||||
// Stdin returns the stdin of the process.
|
||||
func (p *Init) Stdin() io.Closer {
|
||||
return p.stdin
|
||||
}
|
||||
|
||||
// Runtime returns the OCI runtime configured for the init process
|
||||
// Runtime returns the OCI runtime configured for the init process.
|
||||
func (p *Init) Runtime() *runsc.Runsc {
|
||||
return p.runtime
|
||||
}
|
||||
|
||||
// Exec returns a new child process
|
||||
// Exec returns a new child process.
|
||||
func (p *Init) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@@ -398,7 +398,7 @@ func (p *Init) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Proce
|
||||
return p.initState.Exec(ctx, path, r)
|
||||
}
|
||||
|
||||
// exec returns a new exec'd process
|
||||
// exec returns a new exec'd process.
|
||||
func (p *Init) exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
|
||||
// process exec request
|
||||
var spec specs.Process
|
||||
@@ -424,7 +424,7 @@ func (p *Init) exec(ctx context.Context, path string, r *ExecConfig) (proc.Proce
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// Stdio of the process
|
||||
// Stdio returns the stdio of the process.
|
||||
func (p *Init) Stdio() proc.Stdio {
|
||||
return p.stdio
|
||||
}
|
||||
@@ -437,11 +437,11 @@ func (p *Init) runtimeError(rErr error, msg string) error {
|
||||
rMsg, err := getLastRuntimeError(p.runtime)
|
||||
switch {
|
||||
case err != nil:
|
||||
return errors.Wrapf(rErr, "%s: %s (%s)", msg, "unable to retrieve OCI runtime error", err.Error())
|
||||
return fmt.Errorf("%s: %w (unable to retrieve OCI runtime error: %v)", msg, rErr, err)
|
||||
case rMsg == "":
|
||||
return errors.Wrap(rErr, msg)
|
||||
return fmt.Errorf("%s: %w", msg, rErr)
|
||||
default:
|
||||
return errors.Errorf("%s: %s", msg, rMsg)
|
||||
return fmt.Errorf("%s: %s", msg, rMsg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ package proc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/runtime/proc"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type initState interface {
|
||||
@@ -46,7 +46,7 @@ func (s *createdState) transition(name string) error {
|
||||
case "deleted":
|
||||
s.p.initState = &deletedState{}
|
||||
default:
|
||||
return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func (s *runningState) transition(name string) error {
|
||||
case "stopped":
|
||||
s.p.initState = &stoppedState{p: s.p}
|
||||
default:
|
||||
return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -117,11 +117,11 @@ func (s *runningState) Resize(ws console.WinSize) error {
|
||||
}
|
||||
|
||||
func (s *runningState) Start(ctx context.Context) error {
|
||||
return errors.Errorf("cannot start a running process")
|
||||
return fmt.Errorf("cannot start a running process")
|
||||
}
|
||||
|
||||
func (s *runningState) Delete(ctx context.Context) error {
|
||||
return errors.Errorf("cannot delete a running process")
|
||||
return fmt.Errorf("cannot delete a running process")
|
||||
}
|
||||
|
||||
func (s *runningState) Kill(ctx context.Context, sig uint32, all bool) error {
|
||||
@@ -149,17 +149,17 @@ func (s *stoppedState) transition(name string) error {
|
||||
case "deleted":
|
||||
s.p.initState = &deletedState{}
|
||||
default:
|
||||
return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *stoppedState) Resize(ws console.WinSize) error {
|
||||
return errors.Errorf("cannot resize a stopped container")
|
||||
return fmt.Errorf("cannot resize a stopped container")
|
||||
}
|
||||
|
||||
func (s *stoppedState) Start(ctx context.Context) error {
|
||||
return errors.Errorf("cannot start a stopped process")
|
||||
return fmt.Errorf("cannot start a stopped process")
|
||||
}
|
||||
|
||||
func (s *stoppedState) Delete(ctx context.Context) error {
|
||||
@@ -178,5 +178,5 @@ func (s *stoppedState) SetExited(status int) {
|
||||
}
|
||||
|
||||
func (s *stoppedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
|
||||
return nil, errors.Errorf("cannot exec in a stopped state")
|
||||
return nil, fmt.Errorf("cannot exec in a stopped state")
|
||||
}
|
||||
|
||||
@@ -150,8 +150,9 @@ func (c *countingWriteCloser) Close() error {
|
||||
return c.WriteCloser.Close()
|
||||
}
|
||||
|
||||
// isFifo checks if a file is a fifo
|
||||
// if the file does not exist then it returns false
|
||||
// isFifo checks if a file is a fifo.
|
||||
//
|
||||
// If the file does not exist then it returns false.
|
||||
func isFifo(path string) (bool, error) {
|
||||
stat, err := os.Stat(path)
|
||||
if err != nil {
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
package proc
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// RunscRoot is the path to the root runsc state directory
|
||||
// RunscRoot is the path to the root runsc state directory.
|
||||
const RunscRoot = "/run/containerd/runsc"
|
||||
|
||||
func stateName(v interface{}) string {
|
||||
@@ -33,5 +33,5 @@ func stateName(v interface{}) string {
|
||||
case *stoppedState:
|
||||
return "stopped"
|
||||
}
|
||||
panic(errors.Errorf("invalid state %v", v))
|
||||
panic(fmt.Errorf("invalid state %v", v))
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
runc "github.com/containerd/go-runc"
|
||||
)
|
||||
|
||||
// Mount holds filesystem mount configuration
|
||||
// Mount holds filesystem mount configuration.
|
||||
type Mount struct {
|
||||
Type string
|
||||
Source string
|
||||
@@ -31,7 +31,7 @@ type Mount struct {
|
||||
Options []string
|
||||
}
|
||||
|
||||
// CreateConfig hold task creation configuration
|
||||
// CreateConfig hold task creation configuration.
|
||||
type CreateConfig struct {
|
||||
ID string
|
||||
Bundle string
|
||||
@@ -44,7 +44,7 @@ type CreateConfig struct {
|
||||
Options *google_protobuf.Any
|
||||
}
|
||||
|
||||
// ExecConfig holds exec creation configuration
|
||||
// ExecConfig holds exec creation configuration.
|
||||
type ExecConfig struct {
|
||||
ID string
|
||||
Terminal bool
|
||||
@@ -54,14 +54,14 @@ type ExecConfig struct {
|
||||
Spec *google_protobuf.Any
|
||||
}
|
||||
|
||||
// Exit is the type of exit events
|
||||
// Exit is the type of exit events.
|
||||
type Exit struct {
|
||||
Timestamp time.Time
|
||||
ID string
|
||||
Status int
|
||||
}
|
||||
|
||||
// ProcessMonitor monitors process exit changes
|
||||
// ProcessMonitor monitors process exit changes.
|
||||
type ProcessMonitor interface {
|
||||
// Subscribe to process exit changes
|
||||
Subscribe() chan runc.Exit
|
||||
|
||||
@@ -34,8 +34,6 @@ const (
|
||||
// inside the sandbox.
|
||||
var ExitCh = make(chan Exit, bufferSize)
|
||||
|
||||
// TODO(random-liu): This can be a utility.
|
||||
|
||||
// TODO(mlaventure): move to runc package?
|
||||
func getLastRuntimeError(r *runsc.Runsc) (string, error) {
|
||||
if r.Log == "" {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
load("//tools:defs.bzl", "go_library")
|
||||
|
||||
package(licenses = ["notice"])
|
||||
|
||||
go_library(
|
||||
name = "shim",
|
||||
srcs = [
|
||||
"platform.go",
|
||||
"service.go",
|
||||
],
|
||||
visibility = [
|
||||
"//pkg/shim:__subpackages__",
|
||||
"//shim:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//pkg/shim/runsc",
|
||||
"//pkg/shim/v1/proc",
|
||||
"//pkg/shim/v1/utils",
|
||||
"@com_github_containerd_console//:go_default_library",
|
||||
"@com_github_containerd_containerd//api/events:go_default_library",
|
||||
"@com_github_containerd_containerd//api/types/task:go_default_library",
|
||||
"@com_github_containerd_containerd//errdefs:go_default_library",
|
||||
"@com_github_containerd_containerd//events:go_default_library",
|
||||
"@com_github_containerd_containerd//log:go_default_library",
|
||||
"@com_github_containerd_containerd//mount:go_default_library",
|
||||
"@com_github_containerd_containerd//namespaces:go_default_library",
|
||||
"@com_github_containerd_containerd//runtime:go_default_library",
|
||||
"@com_github_containerd_containerd//runtime/linux/runctypes:go_default_library",
|
||||
"@com_github_containerd_containerd//runtime/proc:go_default_library",
|
||||
"@com_github_containerd_containerd//runtime/v1/shim:go_default_library",
|
||||
"@com_github_containerd_containerd//runtime/v1/shim/v1:go_default_library",
|
||||
"@com_github_containerd_fifo//:go_default_library",
|
||||
"@com_github_containerd_typeurl//:go_default_library",
|
||||
"@com_github_gogo_protobuf//types:go_default_library",
|
||||
"@org_golang_google_grpc//codes:go_default_library",
|
||||
"@org_golang_google_grpc//status:go_default_library",
|
||||
],
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user