Merge pull request #8066 from fuweid/cleanup-blockio-init

*: introduce wrapper pkgs for blockio and rdt
This commit is contained in:
Fu Wei
2023-02-13 14:05:32 +08:00
committed by GitHub
16 changed files with 183 additions and 135 deletions

View File

@@ -1,23 +0,0 @@
//go:build !linux
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package tasks
func BlockIOEnabled() bool { return false }
func initBlockIO(configFilePath string) error { return nil }

View File

@@ -1,49 +0,0 @@
//go:build linux
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package tasks
import (
"fmt"
"github.com/containerd/containerd/log"
"github.com/intel/goresctrl/pkg/blockio"
)
var blockIOEnabled bool
func BlockIOEnabled() bool { return blockIOEnabled }
func initBlockIO(configFilePath string) error {
blockIOEnabled = false
if configFilePath == "" {
log.L.Debug("No blockio config file specified, blockio not configured")
return nil
}
if err := blockio.SetConfigFromFile(configFilePath, true); err != nil {
return fmt.Errorf("blockio not enabled: %w", err)
}
blockIOEnabled = true
return nil
}

View File

@@ -39,6 +39,8 @@ import (
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/metadata"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/pkg/blockio"
"github.com/containerd/containerd/pkg/rdt"
"github.com/containerd/containerd/pkg/timeout"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/protobuf"
@@ -141,10 +143,10 @@ func initFunc(ic *plugin.InitContext) (interface{}, error) {
l.monitor.Monitor(t, nil)
}
if err := initBlockIO(config.BlockIOConfigFile); err != nil {
if err := blockio.SetConfig(config.BlockIOConfigFile); err != nil {
log.G(ic.Context).WithError(err).Errorf("blockio initialization failed")
}
if err := initRdt(config.RdtConfigFile); err != nil {
if err := rdt.SetConfig(config.RdtConfigFile); err != nil {
log.G(ic.Context).WithError(err).Errorf("RDT initialization failed")
}

View File

@@ -1,23 +0,0 @@
//go:build !linux || no_rdt
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package tasks
func RdtEnabled() bool { return false }
func initRdt(configFilePath string) error { return nil }

View File

@@ -1,58 +0,0 @@
//go:build linux && !no_rdt
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package tasks
import (
"fmt"
"github.com/containerd/containerd/log"
"github.com/intel/goresctrl/pkg/rdt"
)
const (
// ResctrlPrefix is the prefix used for class/closid directories under the resctrl filesystem
ResctrlPrefix = ""
)
var rdtEnabled bool
func RdtEnabled() bool { return rdtEnabled }
func initRdt(configFilePath string) error {
rdtEnabled = false
if configFilePath == "" {
log.L.Debug("No RDT config file specified, RDT not configured")
return nil
}
if err := rdt.Initialize(ResctrlPrefix); err != nil {
return fmt.Errorf("RDT not enabled: %w", err)
}
if err := rdt.SetConfigFromFile(configFilePath, true); err != nil {
return err
}
rdtEnabled = true
return nil
}