Skip to content

Commit 2dad06f

Browse files
authored
Merge pull request microsoft#106 from Microsoft/more_runc_tests
Expanded runC tests
2 parents 0410aab + 05b0e58 commit 2dad06f

8 files changed

Lines changed: 1130 additions & 101 deletions

File tree

service/gcs/runtime/runc/testbundle/config.json renamed to service/gcs/runtime/runc/cat_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"gid": 0
1616
},
1717
"args": [
18-
"sleep", "100"
18+
"cat"
1919
],
2020
"env": [
2121
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
{
2+
"ociVersion": "1.0.0-rc5",
3+
"platform": {
4+
"os": "linux",
5+
"arch": "amd64"
6+
},
7+
"process": {
8+
"terminal": false,
9+
"consoleSize": {
10+
"height": 0,
11+
"width": 0
12+
},
13+
"user": {
14+
"uid": 0,
15+
"gid": 0
16+
},
17+
"args": [
18+
"sh", "-c", "echo testerr >&2 && cat"
19+
],
20+
"env": [
21+
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
22+
"TERM=xterm"
23+
],
24+
"cwd": "/",
25+
"capabilities": {
26+
"bounding": [
27+
"CAP_AUDIT_WRITE",
28+
"CAP_KILL",
29+
"CAP_NET_BIND_SERVICE",
30+
"CAP_SYS_ADMIN",
31+
"CAP_NET_ADMIN",
32+
"CAP_SETGID",
33+
"CAP_SETUID",
34+
"CAP_CHOWN",
35+
"CAP_FOWNER",
36+
"CAP_DAC_OVERRIDE",
37+
"CAP_NET_RAW"
38+
],
39+
"effective": [
40+
"CAP_AUDIT_WRITE",
41+
"CAP_KILL",
42+
"CAP_NET_BIND_SERVICE",
43+
"CAP_SYS_ADMIN",
44+
"CAP_NET_ADMIN",
45+
"CAP_SETGID",
46+
"CAP_SETUID",
47+
"CAP_CHOWN",
48+
"CAP_FOWNER",
49+
"CAP_DAC_OVERRIDE",
50+
"CAP_NET_RAW"
51+
],
52+
"inheritable": [
53+
"CAP_AUDIT_WRITE",
54+
"CAP_KILL",
55+
"CAP_NET_BIND_SERVICE",
56+
"CAP_SYS_ADMIN",
57+
"CAP_NET_ADMIN",
58+
"CAP_SETGID",
59+
"CAP_SETUID",
60+
"CAP_CHOWN",
61+
"CAP_FOWNER",
62+
"CAP_DAC_OVERRIDE",
63+
"CAP_NET_RAW"
64+
],
65+
"permitted": [
66+
"CAP_AUDIT_WRITE",
67+
"CAP_KILL",
68+
"CAP_NET_BIND_SERVICE",
69+
"CAP_SYS_ADMIN",
70+
"CAP_NET_ADMIN",
71+
"CAP_SETGID",
72+
"CAP_SETUID",
73+
"CAP_CHOWN",
74+
"CAP_FOWNER",
75+
"CAP_DAC_OVERRIDE",
76+
"CAP_NET_RAW"
77+
],
78+
"ambient": [
79+
"CAP_AUDIT_WRITE",
80+
"CAP_KILL",
81+
"CAP_NET_BIND_SERVICE",
82+
"CAP_SYS_ADMIN",
83+
"CAP_NET_ADMIN",
84+
"CAP_SETGID",
85+
"CAP_SETUID",
86+
"CAP_CHOWN",
87+
"CAP_FOWNER",
88+
"CAP_DAC_OVERRIDE",
89+
"CAP_NET_RAW"
90+
]
91+
},
92+
"rlimits": [
93+
{
94+
"type": "RLIMIT_NOFILE",
95+
"hard": 1024,
96+
"soft": 1024
97+
}
98+
],
99+
"noNewPrivileges": true
100+
},
101+
"root": {
102+
"path": "rootfs",
103+
"readonly": true
104+
},
105+
"hostname": "runc",
106+
"mounts": [
107+
{
108+
"destination": "/proc",
109+
"type": "proc",
110+
"source": "proc"
111+
},
112+
{
113+
"destination": "/dev",
114+
"type": "tmpfs",
115+
"source": "tmpfs",
116+
"options": [
117+
"nosuid",
118+
"strictatime",
119+
"mode=755",
120+
"size=65536k"
121+
]
122+
},
123+
{
124+
"destination": "/dev/pts",
125+
"type": "devpts",
126+
"source": "devpts",
127+
"options": [
128+
"nosuid",
129+
"noexec",
130+
"newinstance",
131+
"ptmxmode=0666",
132+
"mode=0620",
133+
"gid=5"
134+
]
135+
},
136+
{
137+
"destination": "/dev/shm",
138+
"type": "tmpfs",
139+
"source": "shm",
140+
"options": [
141+
"nosuid",
142+
"noexec",
143+
"nodev",
144+
"mode=1777",
145+
"size=65536k"
146+
]
147+
},
148+
{
149+
"destination": "/dev/mqueue",
150+
"type": "mqueue",
151+
"source": "mqueue",
152+
"options": [
153+
"nosuid",
154+
"noexec",
155+
"nodev"
156+
]
157+
},
158+
{
159+
"destination": "/sys",
160+
"type": "sysfs",
161+
"source": "sysfs",
162+
"options": [
163+
"nosuid",
164+
"noexec",
165+
"nodev",
166+
"ro"
167+
]
168+
},
169+
{
170+
"destination": "/sys/fs/cgroup",
171+
"type": "cgroup",
172+
"source": "cgroup",
173+
"options": [
174+
"nosuid",
175+
"noexec",
176+
"nodev",
177+
"relatime",
178+
"ro"
179+
]
180+
}
181+
],
182+
"linux": {
183+
"resources": {
184+
"devices": [
185+
{
186+
"allow": false,
187+
"access": "rwm"
188+
}
189+
]
190+
},
191+
"namespaces": [
192+
{
193+
"type": "pid"
194+
},
195+
{
196+
"type": "network"
197+
},
198+
{
199+
"type": "ipc"
200+
},
201+
{
202+
"type": "uts"
203+
},
204+
{
205+
"type": "mount"
206+
}
207+
],
208+
"maskedPaths": [
209+
"/proc/kcore",
210+
"/proc/latency_stats",
211+
"/proc/timer_list",
212+
"/proc/timer_stats",
213+
"/proc/sched_debug",
214+
"/sys/firmware"
215+
],
216+
"readonlyPaths": [
217+
"/proc/asound",
218+
"/proc/bus",
219+
"/proc/fs",
220+
"/proc/irq",
221+
"/proc/sys",
222+
"/proc/sysrq-trigger"
223+
]
224+
}
225+
}

service/gcs/runtime/runc/runc.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ func (c *container) startProcess(tempProcessDir string, hasTerminal bool, stdioS
514514
args = append(args, c.id)
515515

516516
cmd := exec.Command("runc", args...)
517+
517518
if !hasTerminal {
518519
fileSet, err := stdioSet.Files()
519520
if err != nil {
@@ -531,8 +532,9 @@ func (c *container) startProcess(tempProcessDir string, hasTerminal bool, stdioS
531532
cmd.Stderr = fileSet.Err
532533
}
533534
}
534-
if err := cmd.Start(); err != nil {
535-
return nil, errors.Wrapf(err, "failed to start runc create/exec call for container %s", c.id)
535+
536+
if err := cmd.Run(); err != nil {
537+
return nil, errors.Wrapf(err, "failed to run runc create/exec call for container %s", c.id)
536538
}
537539

538540
var relay *stdio.TtyRelay
@@ -541,7 +543,6 @@ func (c *container) startProcess(tempProcessDir string, hasTerminal bool, stdioS
541543
master, err = c.r.getMasterFromSocket(sockListener)
542544
if err != nil {
543545
cmd.Process.Kill()
544-
cmd.Wait()
545546
return nil, errors.Wrapf(err, "failed to get pty master for process in container %s", c.id)
546547
}
547548
// Keep master open for the relay unless there is an error.
@@ -553,10 +554,6 @@ func (c *container) startProcess(tempProcessDir string, hasTerminal bool, stdioS
553554
relay = stdioSet.NewTtyRelay(master)
554555
}
555556

556-
if err := cmd.Wait(); err != nil {
557-
return nil, errors.Wrapf(err, "failed to wait on runc create/exec call for container %s", c.id)
558-
}
559-
560557
// Rename the process's directory to its pid.
561558
pid, err := c.r.readPidFile(filepath.Join(tempProcessDir, "pid"))
562559
if err != nil {

0 commit comments

Comments
 (0)