Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
set default_runtime_name to the runtime to be used
Browse files Browse the repository at this point in the history
Signed-off-by: shysank <sankarans@vmware.com>
  • Loading branch information
shysank committed Feb 11, 2021
1 parent 95d4ba3 commit e79663f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ func UpdateV1Config(config *toml.Tree) error {
"options",
}

defaultRuntimeNamePath := []string{
"plugins",
"cri",
"containerd",
"default_runtime_name",
}

switch runc := config.GetPath(runcPath).(type) {
case *toml.Tree:
runc, _ = toml.Load(runc.String())
Expand All @@ -351,6 +358,7 @@ func UpdateV1Config(config *toml.Tree) error {
config.SetPath(append(defaultRuntimePath, "privileged_without_host_devices"), false)
}
config.SetPath(append(defaultRuntimeOptionsPath, "Runtime"), runtimePath)
config.SetPath(defaultRuntimeNamePath, runtimeClassFlag)
}

return nil
Expand Down Expand Up @@ -379,7 +387,15 @@ func RevertV1Config(config *toml.Tree) error {
"options",
}

defaultRuntimeNamePath := []string{
"plugins",
"cri",
"containerd",
"default_runtime_name",
}

config.DeletePath(runtimeClassPath)
config.DeletePath(defaultRuntimeNamePath)
if runtime, ok := config.GetPath(append(defaultRuntimeOptionsPath, "Runtime")).(string); ok {
if RuntimeBinary == path.Base(runtime) {
config.DeletePath(append(defaultRuntimeOptionsPath, "Runtime"))
Expand Down Expand Up @@ -464,6 +480,12 @@ func UpdateV2Config(config *toml.Tree) error {
runtimeClassFlag,
"options",
}
defaultRuntimeNamePath := []string{
"plugins",
"io.containerd.grpc.v1.cri",
"containerd",
"default_runtime_name",
}

switch runc := config.GetPath(runcPath).(type) {
case *toml.Tree:
Expand All @@ -479,6 +501,7 @@ func UpdateV2Config(config *toml.Tree) error {

if setAsDefaultFlag {
config.SetPath(append(containerdPath, "default_runtime_name"), runtimeClassFlag)
config.SetPath(defaultRuntimeNamePath, runtimeClassFlag)
}

return nil
Expand All @@ -498,8 +521,15 @@ func RevertV2Config(config *toml.Tree) error {
"runtimes",
runtimeClassFlag,
}
defaultRuntimeNamePath := []string{
"plugins",
"io.containerd.grpc.v1.cri",
"containerd",
"default_runtime_name",
}

config.DeletePath(runtimeClassPath)
config.DeletePath(defaultRuntimeNamePath)
if runtime, ok := config.GetPath(append(containerdPath, "default_runtime_name")).(string); ok {
if runtimeClassFlag == runtime {
config.DeletePath(append(containerdPath, "default_runtime_name"))
Expand Down

0 comments on commit e79663f

Please sign in to comment.