Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ jobs:
cache-dependency-path: src/github.com/containerd/cgroups

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: v1.62.0
args: --verbose
version: v2.6.2
skip-cache: true
args: --verbose -D errcheck
working-directory: src/github.com/containerd/cgroups

cgroupV1:
Expand Down
6 changes: 3 additions & 3 deletions cgroup1/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ func Test_getOomControlValue(t *testing.T) {
var (
oneInt64 int64 = 1
zeroInt64 int64 = 0
trueBool bool = true
falseBool bool = false
trueBool = true
falseBool = false
)

type args struct {
Expand Down Expand Up @@ -337,7 +337,7 @@ func Test_getOomControlValue(t *testing.T) {
t.Errorf("getOomControlValue() = %v, want %v", got, tt.want)
return
}
if !(got == nil || tt.want == nil) && *got != *tt.want {
if got != nil && tt.want != nil && *got != *tt.want {
t.Errorf("getOomControlValue() = %v, want %v", got, tt.want)
}
})
Expand Down
33 changes: 18 additions & 15 deletions cgroup1/rdma.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,26 @@ func parseRdmaKV(raw string, entry *v1.RdmaEntry) {
var value uint64
var err error

parts := strings.Split(raw, "=")
switch len(parts) {
case 2:
if parts[1] == "max" {
value = math.MaxUint32
} else {
value, err = parseUint(parts[1], 10, 32)
if err != nil {
return
}
}
if parts[0] == "hca_handle" {
entry.HcaHandles = uint32(value)
} else if parts[0] == "hca_object" {
entry.HcaObjects = uint32(value)
k, v, found := strings.Cut(raw, "=")
if !found {
return
}

if v == "max" {
value = math.MaxUint32
} else {
value, err = parseUint(v, 10, 32)
if err != nil {
return
}
}

switch k {
case "hca_handle":
entry.HcaHandles = uint32(value)
case "hca_object":
entry.HcaObjects = uint32(value)
}
}

func toRdmaEntry(strEntries []string) []*v1.RdmaEntry {
Expand Down
35 changes: 19 additions & 16 deletions cgroup2/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,23 +387,26 @@ func parseRdmaKV(raw string, entry *stats.RdmaEntry) {
var value uint64
var err error

parts := strings.Split(raw, "=")
switch len(parts) {
case 2:
if parts[1] == "max" {
value = math.MaxUint32
} else {
value, err = parseUint(parts[1], 10, 32)
if err != nil {
return
}
}
if parts[0] == "hca_handle" {
entry.HcaHandles = uint32(value)
} else if parts[0] == "hca_object" {
entry.HcaObjects = uint32(value)
k, v, found := strings.Cut(raw, "=")
if !found {
return
}

if v == "max" {
value = math.MaxUint32
} else {
value, err = parseUint(v, 10, 32)
if err != nil {
return
}
}

switch k {
case "hca_handle":
entry.HcaHandles = uint32(value)
case "hca_object":
entry.HcaObjects = uint32(value)
}
}

func toRdmaEntry(strEntries []string) []*stats.RdmaEntry {
Expand Down Expand Up @@ -472,8 +475,8 @@ func hugePageSizes() []string {
if err != nil {
return
}
defer dir.Close()
files, err := dir.Readdirnames(0)
dir.Close()
if err != nil {
return
}
Expand Down
Loading