linux: Honor RuncOptions if set on container
This also fix the type used for RuncOptions.SystemCgroup, hence introducing an API break. Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
@@ -851,3 +851,48 @@ func TestDaemonRestartWithRunningShim(t *testing.T) {
|
||||
t.Errorf("pid %d still exists", pid)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerRuntimeOptions(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, err := newClient(t, address)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
var (
|
||||
image Image
|
||||
ctx, cancel = testContext()
|
||||
id = t.Name()
|
||||
)
|
||||
defer cancel()
|
||||
|
||||
image, err = client.GetImage(ctx, testImage)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
container, err := client.NewContainer(
|
||||
ctx, id,
|
||||
WithNewSpec(withImageConfig(image), withExitStatus(7)),
|
||||
withNewSnapshot(id, image),
|
||||
WithRuntime("io.containerd.runtime.v1.linux", &runcopts.RuncOptions{Runtime: "no-runc"}),
|
||||
)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer container.Delete(ctx, WithSnapshotCleanup)
|
||||
|
||||
task, err := container.NewTask(ctx, empty())
|
||||
if err == nil {
|
||||
t.Errorf("task creation should have failed")
|
||||
task.Delete(ctx)
|
||||
return
|
||||
}
|
||||
if !strings.Contains(err.Error(), `"no-runc"`) {
|
||||
t.Errorf("task creation should have failed because of lack of executable. Instead failed with: %v", err.Error())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user