From 9b1fb82584b6bb780e91fab3ab56282affbb272d Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Fri, 4 Feb 2022 13:16:22 +0200 Subject: [PATCH] cri: fix handling of ignore_rdt_not_enabled_errors config option We were not properly ignoring errors from gorestrl.rdt.ContainerClassFromAnnotations() causing the config option to be ineffective, in practice. Signed-off-by: Markus Lehtonen --- pkg/cri/server/rdt_linux.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/cri/server/rdt_linux.go b/pkg/cri/server/rdt_linux.go index 21b2876de..38a9395c5 100644 --- a/pkg/cri/server/rdt_linux.go +++ b/pkg/cri/server/rdt_linux.go @@ -31,17 +31,21 @@ import ( // container and returns its effective RDT class. func (c *criService) rdtClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) { cls, err := rdt.ContainerClassFromAnnotations(containerName, containerAnnotations, podAnnotations) + + if err == nil { + // Our internal check that RDT has been enabled + if cls != "" && !tasks.RdtEnabled() { + err = fmt.Errorf("RDT disabled, refusing to set RDT class of container %q to %q", containerName, cls) + } + } + if err != nil { + if !tasks.RdtEnabled() && c.config.ContainerdConfig.IgnoreRdtNotEnabledErrors { + logrus.Debugf("continuing create container %s, ignoring rdt not enabled (%v)", containerName, err) + return "", nil + } return "", err } - if cls != "" && !tasks.RdtEnabled() { - 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 }