Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit f3d4e72

Browse files
committed
address feedback
Signed-off-by: Tim Allclair <[email protected]>
1 parent 27d36ad commit f3d4e72

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

cri.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func initCRIService(ic *plugin.InitContext) (interface{}, error) {
108108
return s, nil
109109
}
110110

111-
// validateConfig validates that the given configuration.
111+
// validateConfig validates the given configuration.
112112
func validateConfig(c *criconfig.Config) error {
113113
// It is an error to provide both an UntrustedWorkloadRuntime & define an 'untrusted' runtime.
114114
if _, ok := c.ContainerdConfig.Runtimes[criconfig.RuntimeUntrusted]; ok {

docs/config.md

+18
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ The explanation and default value of each configuration item are as follows:
6161
runtime_root = ""
6262

6363
# "plugins.cri.containerd.untrusted_workload_runtime" is a runtime to run untrusted workloads on it.
64+
65+
# DEPRECATED: use plugins.cri.runtimes instead. If provided, this runtime is mapped to the
66+
# runtime handler named 'untrusted'. It is a configuration error to provide both the (now
67+
# deprecated) UntrustedWorkloadRuntime and a handler in the Runtimes handler map (below) for
68+
# 'untrusted' workloads at the same time. Please provide one or the other.
6469
[plugins.cri.containerd.untrusted_workload_runtime]
6570
# runtime_type is the runtime type to use in containerd e.g. io.containerd.runtime.v1.linux
6671
runtime_type = ""
@@ -71,6 +76,19 @@ The explanation and default value of each configuration item are as follows:
7176
# runtime_root is the directory used by containerd for runtime state.
7277
runtime_root = ""
7378

79+
# plugins.cri.containerd.runtimes is a map from CRI RuntimeHandler strings, which specify types
80+
# of runtime configurations, to the matching configurations. In this example,
81+
# 'runtime_handler_name' is the RuntimeHandler string to match.
82+
[plugins.cri.containerd.runtimes.runtime_handler_name]
83+
# runtime_type is the runtime type to use in containerd e.g. io.containerd.runtime.v1.linux
84+
runtime_type = ""
85+
86+
# runtime_engine is the name of the runtime engine used by containerd.
87+
runtime_engine = ""
88+
89+
# runtime_root is the directory used by containerd for runtime state.
90+
runtime_root = ""
91+
7492
# "plugins.cri.cni" contains config related to cni
7593
[plugins.cri.cni]
7694
# bin_dir is the directory in which the binaries for the plugin is kept.

pkg/config/config.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ type ContainerdConfig struct {
3838
DefaultRuntime Runtime `toml:"default_runtime" json:"defaultRuntime"`
3939
// UntrustedWorkloadRuntime is a runtime to run untrusted workloads on it.
4040
// DEPRECATED: use Runtimes instead. If provided, this runtime is mapped to the runtime handler
41-
// named 'untrusted'. It is a configuration error to provide both.
41+
// named 'untrusted'. It is a configuration error to provide both the (now deprecated)
42+
// UntrustedWorkloadRuntime and a handler in the Runtimes handler map (below) for 'untrusted'
43+
// workloads at the same time. Please provide one or the other.
4244
UntrustedWorkloadRuntime Runtime `toml:"untrusted_workload_runtime" json:"untrustedWorkloadRuntime"`
43-
// Runtimes maps a CRI RuntimeHandler string to a runtime configuration.
45+
// Runtimes is a map from CRI RuntimeHandler strings, which specify types of runtime
46+
// configurations, to the matching configurations.
4447
Runtimes map[string]Runtime `toml:"runtimes" json:"runtimes"`
4548
// NoPivot disables pivot-root (linux only), required when running a container in a RamDisk with runc
4649
NoPivot bool `toml:"no_pivot" json:"noPivot"`
@@ -191,5 +194,5 @@ func DefaultConfig() PluginConfig {
191194

192195
const (
193196
// RuntimeUntrusted is the implicit runtime defined for ContainerdConfig.UntrustedWorkloadRuntime
194-
RuntimeUntrusted = "unstrusted"
197+
RuntimeUntrusted = "untrusted"
195198
)

pkg/server/sandbox_run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ func hostAccessingSandbox(config *runtime.PodSandboxConfig) bool {
604604
func (c *criService) getSandboxRuntime(config *runtime.PodSandboxConfig, runtimeHandler string) (criconfig.Runtime, error) {
605605
if untrustedWorkload(config) {
606606
// If the untrusted annotation is provided, runtimeHandler MUST be empty.
607-
if runtimeHandler != "" {
607+
if runtimeHandler != "" && runtimeHandler != criconfig.RuntimeUntrusted {
608608
return criconfig.Runtime{}, errors.New("untrusted workload with explicit runtime handler is not allowed")
609609
}
610610

pkg/server/sandbox_run_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,29 @@ func TestGetSandboxRuntime(t *testing.T) {
613613
runtimes: map[string]criconfig.Runtime{criconfig.RuntimeUntrusted: untrustedWorkloadRuntime},
614614
expectedRuntime: untrustedWorkloadRuntime,
615615
},
616+
"should use 'untrusted' runtime for untrusted workload & handler": {
617+
sandboxConfig: &runtime.PodSandboxConfig{
618+
Annotations: map[string]string{
619+
annotations.UntrustedWorkload: "true",
620+
},
621+
},
622+
runtimeHandler: "untrusted",
623+
defaultRuntime: defaultRuntime,
624+
runtimes: map[string]criconfig.Runtime{criconfig.RuntimeUntrusted: untrustedWorkloadRuntime},
625+
expectedRuntime: untrustedWorkloadRuntime,
626+
},
627+
"should return an error if untrusted annotation with conflicting handler": {
628+
sandboxConfig: &runtime.PodSandboxConfig{
629+
Annotations: map[string]string{
630+
annotations.UntrustedWorkload: "true",
631+
},
632+
},
633+
runtimeHandler: "foo",
634+
defaultRuntime: defaultRuntime,
635+
untrustedWorkloadRuntime: untrustedWorkloadRuntime,
636+
runtimes: map[string]criconfig.Runtime{"foo": fooRuntime},
637+
expectErr: true,
638+
},
616639
"should use correct runtime for a runtime handler": {
617640
sandboxConfig: &runtime.PodSandboxConfig{},
618641
runtimeHandler: "foo",

0 commit comments

Comments
 (0)