build(deps): bump github.com/intel/goresctrl from 0.5.0 to 0.6.0

Bumps [github.com/intel/goresctrl](https://github.com/intel/goresctrl) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/intel/goresctrl/releases)
- [Commits](https://github.com/intel/goresctrl/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/intel/goresctrl
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-12-27 22:45:39 +00:00
committed by GitHub
parent 8ef7b51661
commit 62a824a4bd
17 changed files with 117 additions and 1059 deletions

View File

@@ -115,7 +115,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"sigs.k8s.io/yaml"
"github.com/intel/goresctrl/pkg/cgroups"
grclog "github.com/intel/goresctrl/pkg/log"
goresctrlpath "github.com/intel/goresctrl/pkg/path"
)
@@ -143,7 +142,7 @@ var log grclog.Logger = grclog.NewLoggerWrapper(stdlog.New(os.Stderr, "[ blockio
// classBlockIO connects user-defined block I/O classes to
// corresponding cgroups blockio controller parameters.
var classBlockIO = map[string]cgroups.BlockIOParameters{}
var classBlockIO = map[string]BlockIOParameters{}
// SetLogger sets the logger instance to be used by the package.
// Examples:
@@ -173,7 +172,7 @@ func SetConfigFromFile(filename string, force bool) error {
// SetConfigFromData parses and applies configuration from data.
func SetConfigFromData(data []byte, force bool) error {
config := &Config{}
if err := yaml.Unmarshal(data, &config); err != nil {
if err := yaml.UnmarshalStrict(data, &config); err != nil {
return err
}
return SetConfig(config, force)
@@ -184,7 +183,7 @@ func SetConfig(opt *Config, force bool) error {
if opt == nil {
// Setting nil configuration clears current configuration.
// SetConfigFromData([]byte(""), dontcare) arrives here.
classBlockIO = map[string]cgroups.BlockIOParameters{}
classBlockIO = map[string]BlockIOParameters{}
return nil
}
@@ -193,7 +192,7 @@ func SetConfig(opt *Config, force bool) error {
log.Warnf("configuration validation partly disabled due to I/O scheduler detection error %#v", ioSchedulerDetectionError.Error())
}
classBlockIO = map[string]cgroups.BlockIOParameters{}
classBlockIO = map[string]BlockIOParameters{}
// Create cgroup blockio parameters for each blockio class
for class := range opt.Classes {
cgBlockIO, err := devicesParametersToCgBlockIO(opt.Classes[class], currentIOSchedulers)
@@ -219,22 +218,6 @@ func GetClasses() []string {
return classNames
}
// SetCgroupClass sets cgroup blkio controller parameters to match
// blockio class. "group" is the cgroup directory of the container
// without mountpoint and controller (blkio) directories:
// "/kubepods/burstable/POD_ID/CONTAINER_ID".
func SetCgroupClass(group string, class string) error {
cgBlockIO, ok := classBlockIO[class]
if !ok {
return fmt.Errorf("no BlockIO parameters for class %#v", class)
}
err := cgroups.ResetBlkioParameters(group, cgBlockIO)
if err != nil {
return fmt.Errorf("assigning container in cgroup %q to class %#v failed: %w", group, class, err)
}
return nil
}
// getCurrentIOSchedulers returns currently active I/O scheduler used for each block device in the system.
// Returns schedulers in a map: {"/dev/sda": "bfq"}
func getCurrentIOSchedulers() (map[string]string, error) {
@@ -274,9 +257,9 @@ func getCurrentIOSchedulers() (map[string]string, error) {
}
// deviceParametersToCgBlockIO converts single blockio class parameters into cgroups blkio format.
func devicesParametersToCgBlockIO(dps []DevicesParameters, currentIOSchedulers map[string]string) (cgroups.BlockIOParameters, error) {
func devicesParametersToCgBlockIO(dps []DevicesParameters, currentIOSchedulers map[string]string) (BlockIOParameters, error) {
errs := []error{}
blkio := cgroups.NewBlockIOParameters()
blkio := NewBlockIOParameters()
for _, dp := range dps {
var err error
var weight, throttleReadBps, throttleWriteBps, throttleReadIOPS, throttleWriteIOPS int64

View File

@@ -0,0 +1,103 @@
// Copyright 2020-2021 Intel Corporation. All Rights Reserved.
//
// 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 blockio
// BlockIOParameters contains cgroups blockio controller parameters.
//
// Effects of Weight and Rate values in SetBlkioParameters():
// Value | Effect
// -------+-------------------------------------------------------------------
//
// -1 | Do not write to cgroups, value is missing.
// 0 | Write to cgroups, will clear the setting as specified in cgroups blkio interface.
// other | Write to cgroups, sets the value.
type BlockIOParameters struct {
Weight int64
WeightDevice DeviceWeights
ThrottleReadBpsDevice DeviceRates
ThrottleWriteBpsDevice DeviceRates
ThrottleReadIOPSDevice DeviceRates
ThrottleWriteIOPSDevice DeviceRates
}
// DeviceWeight contains values for
// - blkio.[io-scheduler].weight
type DeviceWeight struct {
Major int64
Minor int64
Weight int64
}
// DeviceRate contains values for
// - blkio.throttle.read_bps_device
// - blkio.throttle.write_bps_device
// - blkio.throttle.read_iops_device
// - blkio.throttle.write_iops_device
type DeviceRate struct {
Major int64
Minor int64
Rate int64
}
// DeviceWeights contains weights for devices.
type DeviceWeights []DeviceWeight
// DeviceRates contains throttling rates for devices.
type DeviceRates []DeviceRate
// NewBlockIOParameters creates new BlockIOParameters instance.
func NewBlockIOParameters() BlockIOParameters {
return BlockIOParameters{
Weight: -1,
}
}
// DeviceParameters interface provides functions common to DeviceWeights and DeviceRates.
type DeviceParameters interface {
Append(maj, min, val int64)
Update(maj, min, val int64)
}
// Append appends (major, minor, value) to DeviceWeights slice.
func (w *DeviceWeights) Append(maj, min, val int64) {
*w = append(*w, DeviceWeight{Major: maj, Minor: min, Weight: val})
}
// Append appends (major, minor, value) to DeviceRates slice.
func (r *DeviceRates) Append(maj, min, val int64) {
*r = append(*r, DeviceRate{Major: maj, Minor: min, Rate: val})
}
// Update updates device weight in DeviceWeights slice, or appends it if not found.
func (w *DeviceWeights) Update(maj, min, val int64) {
for index, devWeight := range *w {
if devWeight.Major == maj && devWeight.Minor == min {
(*w)[index].Weight = val
return
}
}
w.Append(maj, min, val)
}
// Update updates device rate in DeviceRates slice, or appends it if not found.
func (r *DeviceRates) Update(maj, min, val int64) {
for index, devRate := range *r {
if devRate.Major == maj && devRate.Minor == min {
(*r)[index].Rate = val
return
}
}
r.Append(maj, min, val)
}

View File

@@ -20,8 +20,6 @@ import (
"fmt"
oci "github.com/opencontainers/runtime-spec/specs-go"
"github.com/intel/goresctrl/pkg/cgroups"
)
// OciLinuxBlockIO returns OCI LinuxBlockIO structure corresponding to the class.
@@ -43,7 +41,7 @@ func OciLinuxBlockIO(class string) (*oci.LinuxBlockIO, error) {
return &ociBlockio, nil
}
func ociLinuxWeightDevices(dws cgroups.DeviceWeights) []oci.LinuxWeightDevice {
func ociLinuxWeightDevices(dws DeviceWeights) []oci.LinuxWeightDevice {
if len(dws) == 0 {
return nil
}
@@ -57,7 +55,7 @@ func ociLinuxWeightDevices(dws cgroups.DeviceWeights) []oci.LinuxWeightDevice {
return olwds
}
func ociLinuxThrottleDevices(drs cgroups.DeviceRates) []oci.LinuxThrottleDevice {
func ociLinuxThrottleDevices(drs DeviceRates) []oci.LinuxThrottleDevice {
if len(drs) == 0 {
return nil
}