Skip to content

Commit 0769763

Browse files
Merge pull request #3004 from crosbymichael/multi-shim
io.containerd.runc.v2 with Container Groups
2 parents 31438b6 + 84a2471 commit 0769763

26 files changed

Lines changed: 1552 additions & 443 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ addons:
2828

2929
env:
3030
- TRAVIS_GOOS=linux TEST_RUNTIME=io.containerd.runc.v1 TRAVIS_CGO_ENABLED=1
31+
- TRAVIS_GOOS=linux TEST_RUNTIME=io.containerd.runc.v2 TRAVIS_CGO_ENABLED=1
3132
- TRAVIS_GOOS=linux TEST_RUNTIME=io.containerd.runtime.v1.linux TRAVIS_CGO_ENABLED=1
3233
- TRAVIS_GOOS=darwin TRAVIS_CGO_ENABLED=0
3334

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ bin/containerd-shim-runc-v1: cmd/containerd-shim-runc-v1 FORCE # set !cgo and om
189189
@echo "$(WHALE) bin/containerd-shim-runc-v1"
190190
@CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} -o bin/containerd-shim-runc-v1 ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim-runc-v1
191191

192+
bin/containerd-shim-runc-v2: cmd/containerd-shim-runc-v2 FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220
193+
@echo "$(WHALE) bin/containerd-shim-runc-v2"
194+
@CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} -o bin/containerd-shim-runc-v2 ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim-runc-v2
195+
192196
bin/containerd-shim-runhcs-v1: cmd/containerd-shim-runhcs-v1 FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220
193197
@echo "$(WHALE) bin/containerd-shim-runhcs-v1${BINARY_SUFFIX}"
194198
@CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} -o bin/containerd-shim-runhcs-v1${BINARY_SUFFIX} ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim-runhcs-v1

Makefile.linux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#linux specific settings
1717
WHALE="+"
1818
ONI="-"
19-
COMMANDS += containerd-shim containerd-shim-runc-v1
19+
COMMANDS += containerd-shim containerd-shim-runc-v1 containerd-shim-runc-v2
2020

2121
# check GOOS for cross compile builds
2222
ifeq ($(GOOS),linux)

client.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"net/http"
2525
"runtime"
2626
"strconv"
27+
"strings"
2728
"sync"
2829
"time"
2930

@@ -614,3 +615,20 @@ func (c *Client) Version(ctx context.Context) (Version, error) {
614615
Revision: response.Revision,
615616
}, nil
616617
}
618+
619+
// CheckRuntime returns true if the current runtime matches the expected
620+
// runtime. Providing various parts of the runtime schema will match those
621+
// parts of the expected runtime
622+
func CheckRuntime(current, expected string) bool {
623+
cp := strings.Split(current, ".")
624+
l := len(cp)
625+
for i, p := range strings.Split(expected, ".") {
626+
if i > l {
627+
return false
628+
}
629+
if p != cp[i] {
630+
return false
631+
}
632+
}
633+
return true
634+
}

client_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func TestMain(m *testing.M) {
124124
log.G(ctx).WithFields(logrus.Fields{
125125
"version": version.Version,
126126
"revision": version.Revision,
127+
"runtime": os.Getenv("TEST_RUNTIME"),
127128
}).Info("running tests against containerd")
128129

129130
// pull a seed image

cmd/containerd-shim-runc-v1/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
package main
2020

2121
import (
22-
"github.com/containerd/containerd/runtime/v2/runc"
22+
"github.com/containerd/containerd/runtime/v2/runc/v1"
2323
"github.com/containerd/containerd/runtime/v2/shim"
2424
)
2525

2626
func main() {
27-
shim.Run("io.containerd.runc.v1", runc.New)
27+
shim.Run("io.containerd.runc.v1", v1.New)
2828
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// +build linux
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package main
20+
21+
import (
22+
"github.com/containerd/containerd/runtime/v2/runc/v2"
23+
"github.com/containerd/containerd/runtime/v2/shim"
24+
)
25+
26+
func main() {
27+
shim.Run("io.containerd.runc.v2", v2.New)
28+
}

cmd/containerd-stress/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
"github.com/containerd/containerd"
3232
"github.com/containerd/containerd/namespaces"
33+
"github.com/containerd/containerd/plugin"
3334
metrics "github.com/docker/go-metrics"
3435
"github.com/sirupsen/logrus"
3536
"github.com/urfave/cli"
@@ -146,7 +147,7 @@ func main() {
146147
cli.StringFlag{
147148
Name: "runtime",
148149
Usage: "set the runtime to stress test",
149-
Value: "io.containerd.runtime.v1.linux",
150+
Value: plugin.RuntimeLinuxV1,
150151
},
151152
}
152153
app.Before = func(context *cli.Context) error {

cmd/ctr/commands/run/run_unix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
147147

148148
cOpts = append(cOpts, containerd.WithRuntime(context.String("runtime"), nil))
149149

150+
opts = append(opts, oci.WithAnnotations(commands.LabelArgs(context.StringSlice("label"))))
150151
var s specs.Spec
151152
spec = containerd.WithSpec(&s, opts...)
152153

cmd/ctr/commands/tasks/checkpoint.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/containerd/containerd"
2323
"github.com/containerd/containerd/cmd/ctr/commands"
24+
"github.com/containerd/containerd/plugin"
2425
"github.com/containerd/containerd/runtime/linux/runctypes"
2526
"github.com/containerd/containerd/runtime/v2/runc/options"
2627
"github.com/pkg/errors"
@@ -86,7 +87,7 @@ func withCheckpointOpts(rt string, context *cli.Context) containerd.CheckpointTa
8687
workPath := context.String("work-path")
8788

8889
switch rt {
89-
case "io.containerd.runc.v1":
90+
case plugin.RuntimeRuncV1, plugin.RuntimeRuncV2:
9091
if r.Options == nil {
9192
r.Options = &options.CheckpointOptions{}
9293
}
@@ -101,7 +102,7 @@ func withCheckpointOpts(rt string, context *cli.Context) containerd.CheckpointTa
101102
if workPath != "" {
102103
opts.WorkPath = workPath
103104
}
104-
case "io.containerd.runtime.v1.linux":
105+
case plugin.RuntimeLinuxV1:
105106
if r.Options == nil {
106107
r.Options = &runctypes.CheckpointOptions{}
107108
}

0 commit comments

Comments
 (0)