@@ -12,6 +12,7 @@ import (
1212 "time"
1313
1414 apitypes "github.com/alibaba/pouch/apis/types"
15+ anno "github.com/alibaba/pouch/cri/annotations"
1516 "github.com/alibaba/pouch/daemon/mgr"
1617 "github.com/alibaba/pouch/pkg/utils"
1718
@@ -240,8 +241,13 @@ func makeSandboxPouchConfig(config *runtime.PodSandboxConfig, image string) (*ap
240241 labels := makeLabels (config .GetLabels (), config .GetAnnotations ())
241242 // Apply a label to distinguish sandboxes from regular containers.
242243 labels [containerTypeLabelKey ] = containerTypeLabelSandbox
243-
244244 hc := & apitypes.HostConfig {}
245+
246+ // Apply runtime options.
247+ if annotations := config .GetAnnotations (); annotations != nil {
248+ hc .Runtime = annotations [anno .KubernetesRuntime ]
249+ }
250+
245251 createConfig := & apitypes.ContainerCreateConfig {
246252 ContainerConfig : apitypes.ContainerConfig {
247253 Hostname : strfmt .Hostname (config .Hostname ),
@@ -610,6 +616,19 @@ func applyContainerSecurityContext(lc *runtime.LinuxContainerConfig, podSandboxI
610616
611617// Apply Linux-specific options if applicable.
612618func (c * CriManager ) updateCreateConfig (createConfig * apitypes.ContainerCreateConfig , config * runtime.ContainerConfig , sandboxConfig * runtime.PodSandboxConfig , podSandboxID string ) error {
619+ // Apply runtime options.
620+ if annotations := config .GetAnnotations (); annotations != nil {
621+ createConfig .HostConfig .Runtime = annotations [anno .KubernetesRuntime ]
622+ }
623+ res , err := c .SandboxStore .Get (podSandboxID )
624+ if err != nil {
625+ return fmt .Errorf ("failed to get metadata of %q from SandboxStore: %v" , podSandboxID , err )
626+ }
627+ sandboxMeta := res .(* SandboxMeta )
628+ if sandboxMeta .Runtime != "" {
629+ createConfig .HostConfig .Runtime = sandboxMeta .Runtime
630+ }
631+
613632 if lc := config .GetLinux (); lc != nil {
614633 // TODO: resource restriction.
615634
0 commit comments