Skip to content

Commit d460cf1

Browse files
committed
blockio: add blockio_reconfigure option
Reconfiguring blockio is needed in the following scenarios. - Block devices (/dev/*) change, for example when a CSI driver adds a new block device for a pod. Reconfiguration finds current devices and enables applying appropriate blockio parameters for them. - Blockio class configuration file has been updated in the system. Reconfiguration applies changes without restarting containerd. Signed-off-by: Antti Kervinen <[email protected]>
1 parent 1ff8df5 commit d460cf1

5 files changed

Lines changed: 30 additions & 4 deletions

File tree

docs/man/containerd-config.toml.5.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ documentation.
105105
(Default: **""**). Controls I/O scheduler priority and bandwidth throttling.
106106
See [blockio configuration](https://github.com/intel/goresctrl/blob/main/doc/blockio.md#configuration)
107107
for details of the file format.
108+
- **blockio_reconfigure** (Linux only) specifies if the configuration file must be re-read
109+
and block devices rescanned in the system when it can make a difference. (Default: **false**)
108110
- **rdt_config_file** (Linux only) specifies path to a configuration used for configuring
109111
RDT (Default: **""**). Enables support for Intel RDT, a technology
110112
for cache and memory bandwidth management.
@@ -197,6 +199,7 @@ imports = ["/etc/containerd/runtime_*.toml", "./debug.toml"]
197199
sched_core = true
198200
[plugins."io.containerd.service.v1.tasks-service"]
199201
blockio_config_file = ""
202+
blockio_reconfigure = false
200203
rdt_config_file = ""
201204
```
202205

pkg/cri/server/blockio_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@ func (c *criService) blockIOClassFromAnnotations(containerName string, container
5050
// blockIOToLinuxOci converts blockio class name into the LinuxBlockIO
5151
// structure in the OCI runtime spec.
5252
func blockIOToLinuxOci(className string) (*runtimespec.LinuxBlockIO, error) {
53+
if err := tasks.BlockIOReconfigure(); err != nil {
54+
return nil, err
55+
}
5356
return blockio.OciLinuxBlockIO(className)
5457
}

services/tasks/blockio_default.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ package tasks
2121

2222
func BlockIOEnabled() bool { return false }
2323

24-
func initBlockIO(configFilePath string) error { return nil }
24+
func BlockIOReconfigure() error { return nil }
25+
26+
func initBlockIO(configFilePath string, reconfigure bool) error { return nil }

services/tasks/blockio_linux.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,26 @@ import (
2828
)
2929

3030
var blockIOEnabled bool
31+
var blockIOConfigFilePath string
32+
var blockIOReconfigure bool
3133

3234
func BlockIOEnabled() bool { return blockIOEnabled }
3335

34-
func initBlockIO(configFilePath string) error {
36+
func BlockIOReconfigure() error {
37+
if !blockIOEnabled || !blockIOReconfigure || blockIOConfigFilePath == "" {
38+
return nil
39+
}
40+
err := blockio.SetConfigFromFile(blockIOConfigFilePath, true)
41+
if err != nil {
42+
log.L.Error("blockio reconfiguration error: %w", err)
43+
}
44+
return err
45+
}
46+
47+
func initBlockIO(configFilePath string, reconfigure bool) error {
3548
blockIOEnabled = false
49+
blockIOConfigFilePath = ""
50+
blockIOReconfigure = false
3651

3752
if configFilePath == "" {
3853
log.L.Debug("No blockio config file specified, blockio not configured")
@@ -44,7 +59,8 @@ func initBlockIO(configFilePath string) error {
4459
}
4560

4661
blockIOEnabled = true
62+
blockIOConfigFilePath = configFilePath
63+
blockIOReconfigure = reconfigure
4764

4865
return nil
49-
5066
}

services/tasks/local.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ const (
6969
type Config struct {
7070
// BlockIOConfigFile specifies the path to blockio configuration file
7171
BlockIOConfigFile string `toml:"blockio_config_file" json:"blockioConfigFile"`
72+
// BlockIOReconfigure specifies if the configuration file and system's block devices are reconfigured
73+
BlockIOReconfigure bool `toml:"blockio_reconfigure" json:"blockioReconfigure"`
7274
// RdtConfigFile specifies the path to RDT configuration file
7375
RdtConfigFile string `toml:"rdt_config_file" json:"rdtConfigFile"`
7476
}
@@ -141,7 +143,7 @@ func initFunc(ic *plugin.InitContext) (interface{}, error) {
141143
l.monitor.Monitor(t, nil)
142144
}
143145

144-
if err := initBlockIO(config.BlockIOConfigFile); err != nil {
146+
if err := initBlockIO(config.BlockIOConfigFile, config.BlockIOReconfigure); err != nil {
145147
log.G(ic.Context).WithError(err).Errorf("blockio initialization failed")
146148
}
147149
if err := initRdt(config.RdtConfigFile); err != nil {

0 commit comments

Comments
 (0)