cri: add ignore_rdt_not_enabled_errors config option

Enabling this option effectively causes RDT class of a container to be a
soft requirement. If RDT support has not been enabled the RDT class
setting will not have any effect.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
This commit is contained in:
Markus Lehtonen
2021-09-24 13:00:51 +03:00
parent eba1048163
commit 9c2e3835fa
5 changed files with 23 additions and 4 deletions

View File

@@ -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
}