sandbox: change SandboxMode to Sandboxer

Signed-off-by: Abel Feng <fshb1988@gmail.com>
This commit is contained in:
Abel Feng 2023-06-05 21:01:06 +08:00 committed by f00589305
parent f372b3501b
commit 69e501e7cd
5 changed files with 13 additions and 13 deletions

View File

@ -74,11 +74,11 @@ type Runtime struct {
// while using default snapshotters for operational simplicity.
// See https://github.com/containerd/containerd/issues/6657 for details.
Snapshotter string `toml:"snapshotter" json:"snapshotter"`
// SandboxMode defines which sandbox runtime to use when scheduling pods
// Sandboxer defines which sandbox runtime to use when scheduling pods
// This features requires the new CRI server implementation (enabled by default in 2.0)
// shim - means use whatever Controller implementation provided by shim (e.g. use RemoteController).
// podsandbox - means use Controller implementation from sbserver podsandbox package.
SandboxMode string `toml:"sandbox_mode" json:"sandboxMode"`
Sandboxer string `toml:"sandboxer" json:"sandboxer"`
}
// ContainerdConfig contains toml config related to containerd
@ -383,8 +383,8 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
return errors.New("`privileged_without_host_devices_all_devices_allowed` requires `privileged_without_host_devices` to be enabled")
}
// If empty, use default podSandbox mode
if len(r.SandboxMode) == 0 {
r.SandboxMode = string(ModePodSandbox)
if len(r.Sandboxer) == 0 {
r.Sandboxer = string(ModePodSandbox)
c.ContainerdConfig.Runtimes[k] = r
}
}

View File

@ -61,7 +61,7 @@ func TestValidateConfig(t *testing.T) {
DefaultRuntimeName: RuntimeDefault,
Runtimes: map[string]Runtime{
RuntimeDefault: {
SandboxMode: string(ModePodSandbox),
Sandboxer: string(ModePodSandbox),
},
},
},

View File

@ -71,7 +71,7 @@ func DefaultConfig() PluginConfig {
"runc": {
Type: "io.containerd.runc.v2",
Options: m,
SandboxMode: string(ModePodSandbox),
Sandboxer: string(ModePodSandbox),
},
},
DisableSnapshotAnnotations: true,

View File

@ -275,7 +275,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
)
// When using sandboxed shims, containerd's runtime needs to know which sandbox shim instance to use.
if ociRuntime.SandboxMode == string(criconfig.ModeShim) {
if ociRuntime.Sandboxer == string(criconfig.ModeShim) {
opts = append(opts, containerd.WithSandbox(sandboxID))
}

View File

@ -352,7 +352,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
}
// TODO: get rid of this. sandbox object should no longer have Container field.
if ociRuntime.SandboxMode == string(criconfig.ModePodSandbox) {
if ociRuntime.Sandboxer == string(criconfig.ModePodSandbox) {
container, err := c.client.LoadContainer(ctx, id)
if err != nil {
return nil, fmt.Errorf("failed to load container %q for sandbox: %w", id, err)
@ -691,13 +691,13 @@ func (c *criService) getSandboxController(config *runtime.PodSandboxConfig, runt
return nil, fmt.Errorf("failed to get sandbox runtime: %w", err)
}
// Validate mode
if err = ValidateMode(ociRuntime.SandboxMode); err != nil {
if err = ValidateMode(ociRuntime.Sandboxer); err != nil {
return nil, err
}
// Use sandbox controller to delete sandbox
controller, exist := c.sandboxControllers[criconfig.SandboxControllerMode(ociRuntime.SandboxMode)]
controller, exist := c.sandboxControllers[criconfig.SandboxControllerMode(ociRuntime.Sandboxer)]
if !exist {
return nil, fmt.Errorf("sandbox controller %s not exist", ociRuntime.SandboxMode)
return nil, fmt.Errorf("sandbox controller %s not exist", ociRuntime.Sandboxer)
}
return controller, nil
}