Skip to content
This repository was archived by the owner on Aug 24, 2023. It is now read-only.

Commit 355196d

Browse files
committed
quickfix: propagate runtime
Signed-off-by: Sven Pfennig <s.pfennig@reply.de>
1 parent 6daf9ac commit 355196d

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

core/container_create.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func (ds *dockerService) CreateContainer(
6565
}
6666
containerName := makeContainerName(sandboxConfig, config)
6767
terminationMessagePath, _ := config.Annotations["io.kubernetes.container.terminationMessagePath"]
68+
json, _, err := ds.getPodSandboxDetails(podSandboxID)
6869
createConfig := types.ContainerCreateConfig{
6970
Name: containerName,
7071
Config: &container.Config{
@@ -89,6 +90,7 @@ func (ds *dockerService) CreateContainer(
8990
RestartPolicy: container.RestartPolicy{
9091
Name: "no",
9192
},
93+
Runtime: json.Config.Labels["runtime"],
9294
},
9395
}
9496

core/sandbox_helpers.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ package core
1818

1919
import (
2020
"fmt"
21+
"os"
22+
"strings"
23+
"time"
24+
2125
"github.com/Mirantis/cri-dockerd/libdocker"
2226
"github.com/Mirantis/cri-dockerd/utils"
2327
"github.com/Mirantis/cri-dockerd/utils/errors"
2428
"k8s.io/kubernetes/pkg/credentialprovider"
25-
"os"
26-
"strings"
27-
"time"
2829

2930
"github.com/Mirantis/cri-dockerd/config"
3031
dockertypes "github.com/docker/docker/api/types"
@@ -55,6 +56,19 @@ var (
5556
defaultSandboxGracePeriod = time.Duration(10) * time.Second
5657
)
5758

59+
func (ds *dockerService) getRuntimeFromRuntimeClassName(runtimeClassName string) string {
60+
switch runtimeClassName {
61+
case "spin":
62+
return "io.containerd.spin.v1"
63+
case "wasmedge":
64+
return "io.containerd.wasmedge.v1"
65+
case "docker":
66+
return "docker"
67+
default:
68+
return ""
69+
}
70+
}
71+
5872
// Returns whether the sandbox network is ready, and whether the sandbox is known
5973
func (ds *dockerService) getNetworkReady(podSandboxID string) (bool, bool) {
6074
ds.networkReadyLock.Lock()

core/sandbox_run.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"encoding/json"
2222
"fmt"
23+
2324
"github.com/Mirantis/cri-dockerd/config"
2425
"github.com/Mirantis/cri-dockerd/utils/errors"
2526
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
@@ -51,9 +52,9 @@ func (ds *dockerService) RunPodSandbox(
5152
}
5253

5354
// Step 2: Create the sandbox container.
54-
if r.GetRuntimeHandler() != "" && r.GetRuntimeHandler() != runtimeName {
55-
return nil, fmt.Errorf("RuntimeHandler %q not supported", r.GetRuntimeHandler())
56-
}
55+
//if r.GetRuntimeHandler() != "" && r.GetRuntimeHandler() != runtimeName {
56+
// return nil, fmt.Errorf("RuntimeHandler %q not supported", r.GetRuntimeHandler())
57+
//}
5758
createConfig, err := ds.makeSandboxDockerConfig(containerConfig, image)
5859
if err != nil {
5960
return nil, fmt.Errorf(
@@ -62,6 +63,9 @@ func (ds *dockerService) RunPodSandbox(
6263
err,
6364
)
6465
}
66+
// Map Kubernetes runtimeClassName to Docker runtime.
67+
// TODO: find a better way to pass runtime from K8s Pod to containers
68+
createConfig.Config.Labels["runtime"] = ds.getRuntimeFromRuntimeClassName(r.GetRuntimeHandler())
6569
createResp, err := ds.client.CreateContainer(*createConfig)
6670
if err != nil {
6771
createResp, err = recoverFromCreationConflictIfNeeded(ds.client, *createConfig, err)

0 commit comments

Comments
 (0)