Merge pull request #8066 from fuweid/cleanup-blockio-init
*: introduce wrapper pkgs for blockio and rdt
This commit is contained in:
@@ -21,10 +21,9 @@ package sbserver
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd/services/tasks"
|
||||
"github.com/intel/goresctrl/pkg/blockio"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containerd/containerd/pkg/blockio"
|
||||
)
|
||||
|
||||
// blockIOClassFromAnnotations examines container and pod annotations of a
|
||||
@@ -35,7 +34,7 @@ func (c *criService) blockIOClassFromAnnotations(containerName string, container
|
||||
return "", err
|
||||
}
|
||||
|
||||
if cls != "" && !tasks.BlockIOEnabled() {
|
||||
if cls != "" && !blockio.IsEnabled() {
|
||||
if c.config.ContainerdConfig.IgnoreBlockIONotEnabledErrors {
|
||||
cls = ""
|
||||
logrus.Debugf("continuing create container %s, ignoring blockio not enabled (%v)", containerName, err)
|
||||
@@ -45,9 +44,3 @@ func (c *criService) blockIOClassFromAnnotations(containerName string, container
|
||||
}
|
||||
return cls, nil
|
||||
}
|
||||
|
||||
// blockIOToLinuxOci converts blockio class name into the LinuxBlockIO
|
||||
// structure in the OCI runtime spec.
|
||||
func blockIOToLinuxOci(className string) (*runtimespec.LinuxBlockIO, error) {
|
||||
return blockio.OciLinuxBlockIO(className)
|
||||
}
|
||||
|
||||
@@ -18,14 +18,6 @@
|
||||
|
||||
package sbserver
|
||||
|
||||
import (
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
func (c *criService) blockIOClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func blockIOToLinuxOci(className string) (*runtimespec.LinuxBlockIO, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/containerd/containerd/pkg/blockio"
|
||||
"github.com/containerd/containerd/pkg/cri/annotations"
|
||||
criconfig "github.com/containerd/containerd/pkg/cri/config"
|
||||
cio "github.com/containerd/containerd/pkg/cri/io"
|
||||
@@ -639,7 +640,7 @@ func (c *criService) buildLinuxSpec(
|
||||
return nil, fmt.Errorf("failed to set blockio class: %w", err)
|
||||
}
|
||||
if blockIOClass != "" {
|
||||
if linuxBlockIO, err := blockIOToLinuxOci(blockIOClass); err == nil {
|
||||
if linuxBlockIO, err := blockio.ClassNameToLinuxOCI(blockIOClass); err == nil {
|
||||
specOpts = append(specOpts, oci.WithBlockIO(linuxBlockIO))
|
||||
} else {
|
||||
return nil, err
|
||||
|
||||
@@ -21,9 +21,9 @@ package sbserver
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd/services/tasks"
|
||||
"github.com/intel/goresctrl/pkg/rdt"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containerd/containerd/pkg/rdt"
|
||||
)
|
||||
|
||||
// rdtClassFromAnnotations examines container and pod annotations of a
|
||||
@@ -33,13 +33,13 @@ func (c *criService) rdtClassFromAnnotations(containerName string, containerAnno
|
||||
|
||||
if err == nil {
|
||||
// Our internal check that RDT has been enabled
|
||||
if cls != "" && !tasks.RdtEnabled() {
|
||||
if cls != "" && !rdt.IsEnabled() {
|
||||
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 {
|
||||
if !rdt.IsEnabled() && c.config.ContainerdConfig.IgnoreRdtNotEnabledErrors {
|
||||
logrus.Debugf("continuing create container %s, ignoring rdt not enabled (%v)", containerName, err)
|
||||
return "", nil
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@ package server
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd/services/tasks"
|
||||
"github.com/intel/goresctrl/pkg/blockio"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containerd/containerd/pkg/blockio"
|
||||
)
|
||||
|
||||
// blockIOClassFromAnnotations examines container and pod annotations of a
|
||||
@@ -35,7 +34,7 @@ func (c *criService) blockIOClassFromAnnotations(containerName string, container
|
||||
return "", err
|
||||
}
|
||||
|
||||
if cls != "" && !tasks.BlockIOEnabled() {
|
||||
if cls != "" && !blockio.IsEnabled() {
|
||||
if c.config.ContainerdConfig.IgnoreBlockIONotEnabledErrors {
|
||||
cls = ""
|
||||
logrus.Debugf("continuing create container %s, ignoring blockio not enabled (%v)", containerName, err)
|
||||
@@ -45,9 +44,3 @@ func (c *criService) blockIOClassFromAnnotations(containerName string, container
|
||||
}
|
||||
return cls, nil
|
||||
}
|
||||
|
||||
// blockIOToLinuxOci converts blockio class name into the LinuxBlockIO
|
||||
// structure in the OCI runtime spec.
|
||||
func blockIOToLinuxOci(className string) (*runtimespec.LinuxBlockIO, error) {
|
||||
return blockio.OciLinuxBlockIO(className)
|
||||
}
|
||||
|
||||
@@ -18,14 +18,6 @@
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
func (c *criService) blockIOClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func blockIOToLinuxOci(className string) (*runtimespec.LinuxBlockIO, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
"github.com/opencontainers/selinux/go-selinux/label"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
|
||||
"github.com/containerd/containerd/pkg/blockio"
|
||||
"github.com/containerd/containerd/pkg/cri/annotations"
|
||||
"github.com/containerd/containerd/pkg/cri/config"
|
||||
customopts "github.com/containerd/containerd/pkg/cri/opts"
|
||||
@@ -270,7 +271,7 @@ func (c *criService) containerSpec(
|
||||
return nil, fmt.Errorf("failed to set blockio class: %w", err)
|
||||
}
|
||||
if blockIOClass != "" {
|
||||
if linuxBlockIO, err := blockIOToLinuxOci(blockIOClass); err == nil {
|
||||
if linuxBlockIO, err := blockio.ClassNameToLinuxOCI(blockIOClass); err == nil {
|
||||
specOpts = append(specOpts, oci.WithBlockIO(linuxBlockIO))
|
||||
} else {
|
||||
return nil, err
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/pkg/blockio"
|
||||
"github.com/containerd/containerd/pkg/cri/annotations"
|
||||
cstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||
sstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||
@@ -247,7 +248,7 @@ func (a *nriAPI) WithContainerAdjustment() containerd.NewContainerOpts {
|
||||
if className == "" {
|
||||
return nil, nil
|
||||
}
|
||||
blockIO, err := blockIOToLinuxOci(className)
|
||||
blockIO, err := blockio.ClassNameToLinuxOCI(className)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ package server
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd/services/tasks"
|
||||
"github.com/intel/goresctrl/pkg/rdt"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containerd/containerd/pkg/rdt"
|
||||
)
|
||||
|
||||
// rdtClassFromAnnotations examines container and pod annotations of a
|
||||
@@ -33,13 +33,13 @@ func (c *criService) rdtClassFromAnnotations(containerName string, containerAnno
|
||||
|
||||
if err == nil {
|
||||
// Our internal check that RDT has been enabled
|
||||
if cls != "" && !tasks.RdtEnabled() {
|
||||
if cls != "" && !rdt.IsEnabled() {
|
||||
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 {
|
||||
if !rdt.IsEnabled() && c.config.ContainerdConfig.IgnoreRdtNotEnabledErrors {
|
||||
logrus.Debugf("continuing create container %s, ignoring rdt not enabled (%v)", containerName, err)
|
||||
return "", nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user