Skip to content

Commit e6e2439

Browse files
authored
Merge branch 'master' into fix-integration
2 parents 9c36ffb + 593914b commit e6e2439

File tree

157 files changed

+8668
-3871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+8668
-3871
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ before_install:
2424
- sudo apt-get install -y libseccomp-dev libapparmor-dev
2525
- go get -u github.com/golang/lint/golint
2626
- go get -u github.com/vbatts/git-validation
27-
- go get -u github.com/mvdan/sh/cmd/shfmt
2827
- env | grep TRAVIS_
2928

3029
script:
3130
- git-validation -run DCO,short-subject -v
3231
- make BUILDTAGS="${BUILDTAGS}"
33-
- make BUILDTAGS="${BUILDTAGS}" clean validate test
32+
- make BUILDTAGS="${BUILDTAGS}" clean ci

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RUN apt-get update && apt-get install -y \
2222
protobuf-c-compiler \
2323
protobuf-compiler \
2424
python-minimal \
25+
uidmap \
2526
--no-install-recommends \
2627
&& apt-get clean
2728

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ Rohit Jnagal <[email protected]> (@rjnagal)
33
Victor Marmol <[email protected]> (@vmarmol)
44
Mrunal Patel <[email protected]> (@mrunalp)
55
Daniel, Dao Quang Minh <[email protected]> (@dqminh)
6-
Andrey Vagin <[email protected]> (@avagin)
76
Qiang Huang <[email protected]> (@hqhq)
87
Aleksa Sarai <[email protected]> (@cyphar)

Makefile

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
localtest localunittest localintegration \
33
test unittest integration
44

5+
GO := go
6+
57
SOURCES := $(shell find . 2>&1 | grep -E '.*\.(c|h|go)$$')
68
PREFIX := $(DESTDIR)/usr/local
79
BINDIR := $(PREFIX)/sbin
@@ -27,50 +29,28 @@ SHELL := $(shell command -v bash 2>/dev/null)
2729
.DEFAULT: runc
2830

2931
runc: $(SOURCES)
30-
go build -i $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc .
32+
$(GO) build -buildmode=pie $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc .
3133

3234
all: runc recvtty
3335

3436
recvtty: contrib/cmd/recvtty/recvtty
3537

3638
contrib/cmd/recvtty/recvtty: $(SOURCES)
37-
go build -i $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
39+
$(GO) build -buildmode=pie $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
3840

3941
static: $(SOURCES)
40-
CGO_ENABLED=1 go build -i $(EXTRA_FLAGS) -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o runc .
41-
CGO_ENABLED=1 go build -i $(EXTRA_FLAGS) -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
42+
CGO_ENABLED=1 $(GO) build $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo cgo static_build" -installsuffix netgo -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o runc .
43+
CGO_ENABLED=1 $(GO) build $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo cgo static_build" -installsuffix netgo -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
4244

4345
release:
44-
@flag_list=(seccomp selinux apparmor static); \
45-
unset expression; \
46-
for flag in "$${flag_list[@]}"; do \
47-
expression+="' '{'',$${flag}}"; \
48-
done; \
49-
eval profile_list=("$$expression"); \
50-
for profile in "$${profile_list[@]}"; do \
51-
output=${RELEASE_DIR}/runc; \
52-
for flag in $$profile; do \
53-
output+=."$$flag"; \
54-
done; \
55-
tags="$$profile"; \
56-
ldflags="-X main.gitCommit=${COMMIT} -X main.version=${VERSION}"; \
57-
CGO_ENABLED=; \
58-
[[ "$$profile" =~ static ]] && { \
59-
tags="$${tags/static/static_build}"; \
60-
tags+=" cgo"; \
61-
ldflags+=" -w -extldflags -static"; \
62-
CGO_ENABLED=1; \
63-
}; \
64-
echo "Building target: $$output"; \
65-
go build -i $(EXTRA_FLAGS) -ldflags "$$ldflags $(EXTRA_LDFLAGS)" -tags "$$tags" -o "$$output" .; \
66-
done
46+
script/release.sh -r release/$(VERSION) -v $(VERSION)
6747

6848
dbuild: runcimage
6949
docker run --rm -v $(CURDIR):/go/src/$(PROJECT) --privileged $(RUNC_IMAGE) make clean all
7050

7151
lint:
72-
go vet $(allpackages)
73-
go fmt $(allpackages)
52+
$(GO) vet $(allpackages)
53+
$(GO) fmt $(allpackages)
7454

7555
man:
7656
man/md2man-all.sh
@@ -88,7 +68,7 @@ unittest: runcimage
8868
docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localunittest
8969

9070
localunittest: all
91-
go test -timeout 3m -tags "$(BUILDTAGS)" ${TESTFLAGS} -v $(allpackages)
71+
$(GO) test -timeout 3m -tags "$(BUILDTAGS)" ${TESTFLAGS} -v $(allpackages)
9272

9373
integration: runcimage
9474
docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localintegration
@@ -97,11 +77,10 @@ localintegration: all
9777
bats -t tests/integration${TESTFLAGS}
9878

9979
rootlessintegration: runcimage
100-
docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) --cap-drop=ALL -u rootless $(RUNC_IMAGE) make localintegration
80+
docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localrootlessintegration
10181

102-
# FIXME: This should not be separate from rootlessintegration's method of running.
10382
localrootlessintegration: all
104-
sudo -u rootless -H PATH="${PATH}" bats -t tests/integration${TESTFLAGS}
83+
tests/rootless.sh
10584

10685
shell: all
10786
docker run -e TESTFLAGS -ti --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) bash
@@ -133,10 +112,10 @@ clean:
133112

134113
validate:
135114
script/validate-gofmt
136-
go vet $(allpackages)
115+
$(GO) vet $(allpackages)
137116

138-
ci: validate localtest
117+
ci: validate test release
139118

140119
# memoize allpackages, so that it's executed only once and only if used
141-
_allpackages = $(shell go list ./... | grep -v vendor)
120+
_allpackages = $(shell $(GO) list ./... | grep -v vendor)
142121
allpackages = $(if $(__allpackages),,$(eval __allpackages := $$(_allpackages)))$(__allpackages)

README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,33 @@ Your process field in the `config.json` should look like this below with `"termi
145145
"TERM=xterm"
146146
],
147147
"cwd": "/",
148-
"capabilities": [
149-
"CAP_AUDIT_WRITE",
150-
"CAP_KILL",
151-
"CAP_NET_BIND_SERVICE"
152-
],
148+
"capabilities": {
149+
"bounding": [
150+
"CAP_AUDIT_WRITE",
151+
"CAP_KILL",
152+
"CAP_NET_BIND_SERVICE"
153+
],
154+
"effective": [
155+
"CAP_AUDIT_WRITE",
156+
"CAP_KILL",
157+
"CAP_NET_BIND_SERVICE"
158+
],
159+
"inheritable": [
160+
"CAP_AUDIT_WRITE",
161+
"CAP_KILL",
162+
"CAP_NET_BIND_SERVICE"
163+
],
164+
"permitted": [
165+
"CAP_AUDIT_WRITE",
166+
"CAP_KILL",
167+
"CAP_NET_BIND_SERVICE"
168+
],
169+
"ambient": [
170+
"CAP_AUDIT_WRITE",
171+
"CAP_KILL",
172+
"CAP_NET_BIND_SERVICE"
173+
]
174+
},
153175
"rlimits": [
154176
{
155177
"type": "RLIMIT_NOFILE",
@@ -161,7 +183,7 @@ Your process field in the `config.json` should look like this below with `"termi
161183
},
162184
```
163185

164-
Now we can go though the lifecycle operations in your shell.
186+
Now we can go through the lifecycle operations in your shell.
165187

166188

167189
```bash

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0-rc3
1+
1.0.0-rc4+dev

checkpoint.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ checkpointed.`,
3030
cli.BoolFlag{Name: "tcp-established", Usage: "allow open tcp connections"},
3131
cli.BoolFlag{Name: "ext-unix-sk", Usage: "allow external unix sockets"},
3232
cli.BoolFlag{Name: "shell-job", Usage: "allow shell jobs"},
33+
cli.BoolFlag{Name: "lazy-pages", Usage: "use userfaultfd to lazily restore memory pages"},
34+
cli.StringFlag{Name: "status-fd", Value: "", Usage: "criu writes \\0 to this FD once lazy-pages is ready"},
3335
cli.StringFlag{Name: "page-server", Value: "", Usage: "ADDRESS:PORT of the page server"},
3436
cli.BoolFlag{Name: "file-locks", Usage: "handle file locks, for safety"},
3537
cli.BoolFlag{Name: "pre-dump", Usage: "dump container's memory information only, leave the container running after this"},
3638
cli.StringFlag{Name: "manage-cgroups-mode", Value: "", Usage: "cgroups mode: 'soft' (default), 'full' and 'strict'"},
3739
cli.StringSliceFlag{Name: "empty-ns", Usage: "create a namespace, but don't restore its properties"},
40+
cli.BoolFlag{Name: "auto-dedup", Usage: "enable auto deduplication of memory images"},
3841
},
3942
Action: func(context *cli.Context) error {
4043
if err := checkArgs(context, 1, exactArgs); err != nil {

contrib/cmd/recvtty/recvtty.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"os"
2525
"strings"
2626

27-
"github.com/opencontainers/runc/libcontainer"
27+
"github.com/containerd/console"
2828
"github.com/opencontainers/runc/libcontainer/utils"
2929
"github.com/urfave/cli"
3030
)
@@ -101,24 +101,25 @@ func handleSingle(path string) error {
101101
if err != nil {
102102
return err
103103
}
104-
if err = libcontainer.SaneTerminal(master); err != nil {
104+
console, err := console.ConsoleFromFile(master)
105+
if err != nil {
105106
return err
106107
}
107108

108109
// Copy from our stdio to the master fd.
109110
quitChan := make(chan struct{})
110111
go func() {
111-
io.Copy(os.Stdout, master)
112+
io.Copy(os.Stdout, console)
112113
quitChan <- struct{}{}
113114
}()
114115
go func() {
115-
io.Copy(master, os.Stdin)
116+
io.Copy(console, os.Stdin)
116117
quitChan <- struct{}{}
117118
}()
118119

119120
// Only close the master fd once we've stopped copying.
120121
<-quitChan
121-
master.Close()
122+
console.Close()
122123
return nil
123124
}
124125

events.go

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import (
99
"sync"
1010
"time"
1111

12-
"github.com/Sirupsen/logrus"
1312
"github.com/opencontainers/runc/libcontainer"
1413
"github.com/opencontainers/runc/libcontainer/cgroups"
14+
"github.com/opencontainers/runc/libcontainer/intelrdt"
15+
16+
"github.com/sirupsen/logrus"
1517
"github.com/urfave/cli"
1618
)
1719

@@ -24,11 +26,12 @@ type event struct {
2426

2527
// stats is the runc specific stats structure for stability when encoding and decoding stats.
2628
type stats struct {
27-
CPU cpu `json:"cpu"`
28-
Memory memory `json:"memory"`
29-
Pids pids `json:"pids"`
30-
Blkio blkio `json:"blkio"`
31-
Hugetlb map[string]hugetlb `json:"hugetlb"`
29+
CPU cpu `json:"cpu"`
30+
Memory memory `json:"memory"`
31+
Pids pids `json:"pids"`
32+
Blkio blkio `json:"blkio"`
33+
Hugetlb map[string]hugetlb `json:"hugetlb"`
34+
IntelRdt intelRdt `json:"intel_rdt"`
3235
}
3336

3437
type hugetlb struct {
@@ -95,6 +98,23 @@ type memory struct {
9598
Raw map[string]uint64 `json:"raw,omitempty"`
9699
}
97100

101+
type l3CacheInfo struct {
102+
CbmMask string `json:"cbm_mask,omitempty"`
103+
MinCbmBits uint64 `json:"min_cbm_bits,omitempty"`
104+
NumClosids uint64 `json:"num_closids,omitempty"`
105+
}
106+
107+
type intelRdt struct {
108+
// The read-only L3 cache information
109+
L3CacheInfo *l3CacheInfo `json:"l3_cache_info,omitempty"`
110+
111+
// The read-only L3 cache schema in root
112+
L3CacheSchemaRoot string `json:"l3_cache_schema_root,omitempty"`
113+
114+
// The L3 cache schema in 'container_id' group
115+
L3CacheSchema string `json:"l3_cache_schema,omitempty"`
116+
}
117+
98118
var eventsCommand = cli.Command{
99119
Name: "events",
100120
Usage: "display container events such as OOM notifications, cpu, memory, and IO usage statistics",
@@ -226,6 +246,13 @@ func convertLibcontainerStats(ls *libcontainer.Stats) *stats {
226246
for k, v := range cg.HugetlbStats {
227247
s.Hugetlb[k] = convertHugtlb(v)
228248
}
249+
250+
if is := ls.IntelRdtStats; is != nil {
251+
s.IntelRdt.L3CacheInfo = convertL3CacheInfo(is.L3CacheInfo)
252+
s.IntelRdt.L3CacheSchemaRoot = is.L3CacheSchemaRoot
253+
s.IntelRdt.L3CacheSchema = is.L3CacheSchema
254+
}
255+
229256
return &s
230257
}
231258

@@ -258,3 +285,11 @@ func convertBlkioEntry(c []cgroups.BlkioStatEntry) []blkioEntry {
258285
}
259286
return out
260287
}
288+
289+
func convertL3CacheInfo(i *intelrdt.L3CacheInfo) *l3CacheInfo {
290+
return &l3CacheInfo{
291+
CbmMask: i.CbmMask,
292+
MinCbmBits: i.MinCbmBits,
293+
NumClosids: i.NumClosids,
294+
}
295+
}

0 commit comments

Comments
 (0)