build(deps): bump github.com/testcontainers/testcontainers-go
Bumps [github.com/testcontainers/testcontainers-go](https://github.com/testcontainers/testcontainers-go) from 0.40.0 to 0.41.0. - [Release notes](https://github.com/testcontainers/testcontainers-go/releases) - [Commits](https://github.com/testcontainers/testcontainers-go/compare/v0.40.0...v0.41.0) --- updated-dependencies: - dependency-name: github.com/testcontainers/testcontainers-go dependency-version: 0.41.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
fef601f104
commit
de59bb63ad
+3
-3
@@ -1,10 +1,10 @@
|
||||
env:
|
||||
CIRRUS_CLONE_DEPTH: 1
|
||||
GO_VERSION: go1.22.2
|
||||
GO_VERSION: go1.25.0
|
||||
|
||||
freebsd_13_task:
|
||||
freebsd_instance:
|
||||
image_family: freebsd-13-2
|
||||
image_family: freebsd-13-5
|
||||
install_script: |
|
||||
pkg install -y go
|
||||
GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest
|
||||
@@ -14,7 +14,7 @@ freebsd_13_task:
|
||||
|
||||
freebsd_14_task:
|
||||
freebsd_instance:
|
||||
image_family: freebsd-14-0
|
||||
image_family: freebsd-14-2
|
||||
install_script: |
|
||||
pkg install -y go
|
||||
GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest
|
||||
|
||||
+8
-12
@@ -25,10 +25,13 @@ const (
|
||||
_POSIX2_UPE = -1
|
||||
)
|
||||
|
||||
var clktck struct {
|
||||
sync.Once
|
||||
v int64
|
||||
}
|
||||
var clktck = sync.OnceValue(func() int64 {
|
||||
ci, err := unix.SysctlClockinfo("kern.clockrate")
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
return int64(ci.Hz)
|
||||
})
|
||||
|
||||
func sysconfPOSIX(name int) (int64, error) {
|
||||
// NetBSD does not define all _POSIX_* values used in sysconf_posix.go
|
||||
@@ -54,14 +57,7 @@ func sysconf(name int) (int64, error) {
|
||||
}
|
||||
return -1, nil
|
||||
case SC_CLK_TCK:
|
||||
// TODO: use sync.OnceValue once Go 1.21 is the minimal supported version
|
||||
clktck.Do(func() {
|
||||
clktck.v = -1
|
||||
if ci, err := unix.SysctlClockinfo("kern.clockrate"); err == nil {
|
||||
clktck.v = int64(ci.Hz)
|
||||
}
|
||||
})
|
||||
return clktck.v, nil
|
||||
return clktck(), nil
|
||||
case SC_NGROUPS_MAX:
|
||||
return sysctl32("kern.ngroups"), nil
|
||||
case SC_JOB_CONTROL:
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
env:
|
||||
CIRRUS_CLONE_DEPTH: 1
|
||||
GO_VERSION: go1.22.2
|
||||
GO_VERSION: go1.25.0
|
||||
|
||||
freebsd_13_task:
|
||||
freebsd_instance:
|
||||
image_family: freebsd-13-2
|
||||
image_family: freebsd-13-5
|
||||
install_script: |
|
||||
pkg install -y go
|
||||
GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest
|
||||
@@ -14,7 +14,7 @@ freebsd_13_task:
|
||||
|
||||
freebsd_14_task:
|
||||
freebsd_instance:
|
||||
image_family: freebsd-14-0
|
||||
image_family: freebsd-14-2
|
||||
install_script: |
|
||||
pkg install -y go
|
||||
GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest
|
||||
|
||||
+23
@@ -73,3 +73,26 @@ func GetPossible() (int, error) {
|
||||
func GetPresent() (int, error) {
|
||||
return getPresent()
|
||||
}
|
||||
|
||||
// ListOffline returns the list of offline CPUs. See [GetOffline] for details on
|
||||
// when a CPU is considered offline.
|
||||
func ListOffline() ([]int, error) {
|
||||
return listOffline()
|
||||
}
|
||||
|
||||
// ListOnline returns the list of CPUs that are online and being scheduled.
|
||||
func ListOnline() ([]int, error) {
|
||||
return listOnline()
|
||||
}
|
||||
|
||||
// ListPossible returns the list of possible CPUs. See [GetPossible] for
|
||||
// details on when a CPU is considered possible.
|
||||
func ListPossible() ([]int, error) {
|
||||
return listPossible()
|
||||
}
|
||||
|
||||
// ListPresent returns the list of present CPUs. See [GetPresent] for
|
||||
// details on when a CPU is considered present.
|
||||
func ListPresent() ([]int, error) {
|
||||
return listPresent()
|
||||
}
|
||||
|
||||
+85
-12
@@ -15,6 +15,7 @@
|
||||
package numcpus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -23,7 +24,14 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const sysfsCPUBasePath = "/sys/devices/system/cpu"
|
||||
const (
|
||||
sysfsCPUBasePath = "/sys/devices/system/cpu"
|
||||
|
||||
offline = "offline"
|
||||
online = "online"
|
||||
possible = "possible"
|
||||
present = "present"
|
||||
)
|
||||
|
||||
func getFromCPUAffinity() (int, error) {
|
||||
var cpuSet unix.CPUSet
|
||||
@@ -33,19 +41,28 @@ func getFromCPUAffinity() (int, error) {
|
||||
return cpuSet.Count(), nil
|
||||
}
|
||||
|
||||
func readCPURange(file string) (int, error) {
|
||||
func readCPURangeWith[T any](file string, f func(cpus string) (T, error)) (T, error) {
|
||||
var zero T
|
||||
buf, err := os.ReadFile(filepath.Join(sysfsCPUBasePath, file))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return zero, err
|
||||
}
|
||||
return parseCPURange(strings.Trim(string(buf), "\n "))
|
||||
return f(string(buf))
|
||||
}
|
||||
|
||||
func parseCPURange(cpus string) (int, error) {
|
||||
func countCPURange(cpus string) (int, error) {
|
||||
cpus = strings.Trim(cpus, "\n ")
|
||||
|
||||
// Treat empty file as valid. This might be the case if there are no offline CPUs in which
|
||||
// case /sys/devices/system/cpu/offline is empty.
|
||||
if cpus == "" {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
n := int(0)
|
||||
for _, cpuRange := range strings.Split(cpus, ",") {
|
||||
if len(cpuRange) == 0 {
|
||||
continue
|
||||
for cpuRange := range strings.SplitSeq(cpus, ",") {
|
||||
if cpuRange == "" {
|
||||
return 0, fmt.Errorf("empty CPU range in CPU string %q", cpus)
|
||||
}
|
||||
from, to, found := strings.Cut(cpuRange, "-")
|
||||
first, err := strconv.ParseUint(from, 10, 32)
|
||||
@@ -60,11 +77,51 @@ func parseCPURange(cpus string) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if last < first {
|
||||
return 0, fmt.Errorf("last CPU in range (%d) less than first (%d)", last, first)
|
||||
}
|
||||
n += int(last - first + 1)
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func listCPURange(cpus string) ([]int, error) {
|
||||
cpus = strings.Trim(cpus, "\n ")
|
||||
|
||||
// See comment in countCPURange.
|
||||
if cpus == "" {
|
||||
return []int{}, nil
|
||||
}
|
||||
|
||||
list := []int{}
|
||||
for cpuRange := range strings.SplitSeq(cpus, ",") {
|
||||
if cpuRange == "" {
|
||||
return nil, fmt.Errorf("empty CPU range in CPU string %q", cpus)
|
||||
}
|
||||
from, to, found := strings.Cut(cpuRange, "-")
|
||||
first, err := strconv.ParseUint(from, 10, 32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !found {
|
||||
// range containing a single element
|
||||
list = append(list, int(first))
|
||||
continue
|
||||
}
|
||||
last, err := strconv.ParseUint(to, 10, 32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if last < first {
|
||||
return nil, fmt.Errorf("last CPU in range (%d) less than first (%d)", last, first)
|
||||
}
|
||||
for cpu := int(first); cpu <= int(last); cpu++ {
|
||||
list = append(list, cpu)
|
||||
}
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func getConfigured() (int, error) {
|
||||
d, err := os.Open(sysfsCPUBasePath)
|
||||
if err != nil {
|
||||
@@ -100,20 +157,36 @@ func getKernelMax() (int, error) {
|
||||
}
|
||||
|
||||
func getOffline() (int, error) {
|
||||
return readCPURange("offline")
|
||||
return readCPURangeWith(offline, countCPURange)
|
||||
}
|
||||
|
||||
func getOnline() (int, error) {
|
||||
if n, err := getFromCPUAffinity(); err == nil {
|
||||
return n, nil
|
||||
}
|
||||
return readCPURange("online")
|
||||
return readCPURangeWith(online, countCPURange)
|
||||
}
|
||||
|
||||
func getPossible() (int, error) {
|
||||
return readCPURange("possible")
|
||||
return readCPURangeWith(possible, countCPURange)
|
||||
}
|
||||
|
||||
func getPresent() (int, error) {
|
||||
return readCPURange("present")
|
||||
return readCPURangeWith(present, countCPURange)
|
||||
}
|
||||
|
||||
func listOffline() ([]int, error) {
|
||||
return readCPURangeWith(offline, listCPURange)
|
||||
}
|
||||
|
||||
func listOnline() ([]int, error) {
|
||||
return readCPURangeWith(online, listCPURange)
|
||||
}
|
||||
|
||||
func listPossible() ([]int, error) {
|
||||
return readCPURangeWith(possible, listCPURange)
|
||||
}
|
||||
|
||||
func listPresent() ([]int, error) {
|
||||
return readCPURangeWith(present, listCPURange)
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// Copyright 2024 Tobias Klauser
|
||||
//
|
||||
// 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.
|
||||
|
||||
//go:build !linux
|
||||
|
||||
package numcpus
|
||||
|
||||
func listOffline() ([]int, error) {
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
|
||||
func listOnline() ([]int, error) {
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
|
||||
func listPossible() ([]int, error) {
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
|
||||
func listPresent() ([]int, error) {
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
Reference in New Issue
Block a user