mirror of
https://github.com/containerd/containerd.git
synced 2026-06-24 08:48:48 +00:00
*: modernize: rangeint
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -92,7 +92,7 @@ func TestRegressionIssue6772(t *testing.T) {
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < maxItem; i++ {
|
||||
for i := range maxItem {
|
||||
id := i
|
||||
wg.Add(1)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func (m *Mount) mount(target string) error {
|
||||
// cmd.CombinedOutput() may intermittently return ECHILD because of our signal handling in shim.
|
||||
// See #4387 and wait(2).
|
||||
const retriesOnECHILD = 10
|
||||
for i := 0; i < retriesOnECHILD; i++ {
|
||||
for range retriesOnECHILD {
|
||||
cmd := exec.Command("mount", args...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err == nil {
|
||||
|
||||
@@ -47,7 +47,7 @@ func BenchmarkBatchRunGetUsernsFD_Concurrent10(b *testing.B) {
|
||||
func benchmarkBatchRunGetUsernsFD(n int) {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(n)
|
||||
for i := 0; i < n; i++ {
|
||||
for range n {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
fd, err := getUsernsFD(testUIDMaps, testGIDMaps)
|
||||
|
||||
@@ -552,7 +552,7 @@ func (m *Mount) mountWithHelper(helperBinary, typePrefix, target string) error {
|
||||
// cmd.CombinedOutput() may intermittently return ECHILD because of our signal handling in shim.
|
||||
// See #4387 and wait(2).
|
||||
const retriesOnECHILD = 10
|
||||
for i := 0; i < retriesOnECHILD; i++ {
|
||||
for range retriesOnECHILD {
|
||||
cmd := exec.Command(helperBinary, args...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err == nil {
|
||||
|
||||
@@ -180,7 +180,7 @@ func benchmarkSnapshotter(b *testing.B, snapshotter snapshots.Snapshotter) {
|
||||
|
||||
var timer time.Time
|
||||
for i := 0; i < b.N; i++ {
|
||||
for l := 0; l < layerCount; l++ {
|
||||
for l := range layerCount {
|
||||
current = fmt.Sprintf("prepare-layer-%d", layerIndex.Add(1))
|
||||
|
||||
timer = time.Now()
|
||||
|
||||
@@ -48,9 +48,9 @@ func TestNriPluginNetworkingSynchronization(t *testing.T) {
|
||||
|
||||
tc.setup()
|
||||
|
||||
for i := 0; i < podCount; i++ {
|
||||
for i := range podCount {
|
||||
podID := tc.runPod(fmt.Sprintf("%s%d", podPrefix, i))
|
||||
for j := 0; j < ctrPerPod; j++ {
|
||||
for j := range ctrPerPod {
|
||||
tc.startContainer(podID, fmt.Sprintf("ctr%d", j))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ version = 3
|
||||
}()
|
||||
|
||||
t.Logf("Creating %d pod sandboxes", n)
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
podCtx := newPodTCtx(t,
|
||||
ctrd.criRuntimeService(t),
|
||||
fmt.Sprintf("test-oom-event-%d", i),
|
||||
|
||||
@@ -375,7 +375,7 @@ func execToExistingContainer(t *testing.T, _ int,
|
||||
|
||||
logSizeChange := false
|
||||
curSize := getFileSize(t, logPath)
|
||||
for i := 0; i < 30; i++ {
|
||||
for range 30 {
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
if curSize < getFileSize(t, logPath) {
|
||||
|
||||
@@ -108,7 +108,7 @@ func TestReload100Pods(t *testing.T) {
|
||||
assert.NoError(t, ctrd.wait(5*time.Minute))
|
||||
}()
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
for i := range 100 {
|
||||
podCtx := newPodTCtx(t,
|
||||
ctrd.criRuntimeService(t),
|
||||
fmt.Sprintf("test-restart-%d", i),
|
||||
|
||||
@@ -306,7 +306,7 @@ func (t *tcShaper) Reset(cidr string) error {
|
||||
if !found {
|
||||
return fmt.Errorf("failed to find cidr: %s on interface: %s", cidr, t.iface)
|
||||
}
|
||||
for i := 0; i < len(classAndHandle); i++ {
|
||||
for i := range classAndHandle {
|
||||
if err := t.execAndLog("tc", "filter", "del",
|
||||
"dev", t.iface,
|
||||
"parent", "1:",
|
||||
|
||||
@@ -154,7 +154,7 @@ func TestMountOptionsPageSizeLimit(t *testing.T) {
|
||||
var optionsBuilder strings.Builder
|
||||
optionsBuilder.WriteString("ro")
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
for range 100 {
|
||||
fakeDevice := filepath.Join(tempDir, strings.Repeat("x", 50), "fake_device_"+strings.Repeat("0", 10))
|
||||
opt := "device=" + fakeDevice
|
||||
options = append(options, opt)
|
||||
@@ -225,7 +225,7 @@ func TestMountOptionsPageSizeLimit(t *testing.T) {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("ro")
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
for range 100 {
|
||||
manyOptions = append(manyOptions, "dax=always")
|
||||
builder.WriteString(",dax=always")
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ func (p *PoolDevice) createSnapshot(ctx context.Context, baseInfo, snapInfo *Dev
|
||||
func (p *PoolDevice) SuspendDevice(ctx context.Context, deviceName string) error {
|
||||
// Retry logic for suspend operations to handle resource contention
|
||||
var lastErr error
|
||||
for attempt := 0; attempt < 3; attempt++ {
|
||||
for attempt := range 3 {
|
||||
if attempt > 0 {
|
||||
// Add exponential backoff between retry attempts
|
||||
time.Sleep(time.Duration(100*attempt) * time.Millisecond)
|
||||
@@ -427,7 +427,7 @@ func (p *PoolDevice) SuspendDevice(ctx context.Context, deviceName string) error
|
||||
func (p *PoolDevice) ResumeDevice(ctx context.Context, deviceName string) error {
|
||||
// Retry logic for resume operations to handle resource contention
|
||||
var lastErr error
|
||||
for attempt := 0; attempt < 3; attempt++ {
|
||||
for attempt := range 3 {
|
||||
if attempt > 0 {
|
||||
// Add exponential backoff between retry attempts
|
||||
time.Sleep(time.Duration(100*attempt) * time.Millisecond)
|
||||
|
||||
@@ -508,7 +508,7 @@ func (s *blockCIMSnapshotter) prepareMergedCIM(ctx context.Context, snapshotIDs
|
||||
}
|
||||
|
||||
sourceCIMs := make([]*cimfs.BlockCIM, 0, len(snapshotIDs))
|
||||
for i := 0; i < len(snapshotIDs); i++ {
|
||||
for i := range snapshotIDs {
|
||||
sCIM, err := s.getSnapshotBlockCIM(ctx, snapshotIDs[i], snInfos[i])
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user