diff --git a/docs/cri/config.md b/docs/cri/config.md index 5c0940098..b678b25d1 100644 --- a/docs/cri/config.md +++ b/docs/cri/config.md @@ -143,6 +143,14 @@ version = 2 # default_runtime_name is the default runtime name to use. default_runtime_name = "runc" + # ignore_rdt_not_enabled_errors disables RDT related errors when RDT + # support has not been enabled. Intel RDT is a technology for cache and + # memory bandwidth management. By default, trying to set the RDT class of + # a container via annotations produces an error if RDT hasn't been enabled. + # This config option practically enables a "soft" mode for RDT where these + # errors are ignored and the container gets no RDT class. + ignore_rdt_not_enabled_errors = false + # 'plugins."io.containerd.grpc.v1.cri".containerd.default_runtime' is the runtime to use in containerd. # DEPRECATED: use `default_runtime_name` and `plugins."io.containerd.grpc.v1.cri".containerd.runtimes` instead. [plugins."io.containerd.grpc.v1.cri".containerd.default_runtime] diff --git a/pkg/cri/config/config.go b/pkg/cri/config/config.go index e913aa4ab..54fb4b16d 100644 --- a/pkg/cri/config/config.go +++ b/pkg/cri/config/config.go @@ -97,6 +97,10 @@ type ContainerdConfig struct { // remove layers from the content store after successfully unpacking these // layers to the snapshotter. DiscardUnpackedLayers bool `toml:"discard_unpacked_layers" json:"discardUnpackedLayers"` + + // IgnoreRdtNotEnabledErrors is a boolean flag to ignore RDT related errors + // when RDT support has not been enabled. + IgnoreRdtNotEnabledErrors bool `toml:"ignore_rdt_not_enabled_errors" json:"ignoreRdtNotEnabledErrors"` } // CniConfig contains toml config related to cni diff --git a/pkg/cri/server/container_create_linux.go b/pkg/cri/server/container_create_linux.go index 5b1611cc9..e68f754db 100644 --- a/pkg/cri/server/container_create_linux.go +++ b/pkg/cri/server/container_create_linux.go @@ -257,7 +257,7 @@ func (c *criService) containerSpec( supplementalGroups := securityContext.GetSupplementalGroups() // Get RDT class - rdtClass, err := rdtClassFromAnnotations(config.GetMetadata().GetName(), config.Annotations, sandboxConfig.Annotations) + rdtClass, err := c.rdtClassFromAnnotations(config.GetMetadata().GetName(), config.Annotations, sandboxConfig.Annotations) if err != nil { return nil, errors.Wrap(err, "failed to set RDT class") } diff --git a/pkg/cri/server/rdt_linux.go b/pkg/cri/server/rdt_linux.go index d8077c33a..9885da314 100644 --- a/pkg/cri/server/rdt_linux.go +++ b/pkg/cri/server/rdt_linux.go @@ -23,17 +23,24 @@ import ( "github.com/containerd/containerd/services/tasks" "github.com/intel/goresctrl/pkg/rdt" + "github.com/sirupsen/logrus" ) // rdtClassFromAnnotations examines container and pod annotations of a // container and returns its effective RDT class. -func rdtClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) { +func (c *criService) rdtClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) { cls, err := rdt.ContainerClassFromAnnotations(containerName, containerAnnotations, podAnnotations) if err != nil { return "", err } + if cls != "" && !tasks.RdtEnabled() { - return "", fmt.Errorf("RDT disabled, refusing to set RDT class of container %q to %q", containerName, cls) + if c.config.ContainerdConfig.IgnoreRdtNotEnabledErrors { + cls = "" + logrus.Debugf("continuing create container %s, ignoring rdt not enabled (%v)", containerName, err) + } else { + return "", fmt.Errorf("RDT disabled, refusing to set RDT class of container %q to %q", containerName, cls) + } } return cls, nil } diff --git a/pkg/cri/server/rdt_stub_linux.go b/pkg/cri/server/rdt_stub_linux.go index c8882c063..16d3e606e 100644 --- a/pkg/cri/server/rdt_stub_linux.go +++ b/pkg/cri/server/rdt_stub_linux.go @@ -18,6 +18,6 @@ package server -func rdtClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) { +func (c *criService) rdtClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) { return "", nil }