Skip to content

Commit 2bed333

Browse files
committed
fix lint error
1 parent 75b09b4 commit 2bed333

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

test/integration/scheduler_perf/scheduler_perf.go

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
11961196

11971197
results, err := runWorkload(tCtx, tc, w, informerFactory)
11981198
if err != nil {
1199-
tCtx.Fatalf("%w: %s", w.Name, err)
1199+
tCtx.Fatalf("Error running workload %s: %s", w.Name, err)
12001200
}
12011201
dataItems.DataItems = append(dataItems.DataItems, results...)
12021202

@@ -1295,7 +1295,10 @@ func RunIntegrationPerfScheduling(t *testing.T, configFile string) {
12951295
t.Fatalf("workload %s is not valid: %v", w.Name, err)
12961296
}
12971297

1298-
runWorkload(tCtx, tc, w, informerFactory)
1298+
_, err = runWorkload(tCtx, tc, w, informerFactory)
1299+
if err != nil {
1300+
tCtx.Fatalf("Error running workload %s: %s", w.Name, err)
1301+
}
12991302

13001303
if featureGates[features.SchedulerQueueingHints] {
13011304
// In any case, we should make sure InFlightEvents is empty after running the scenario.
@@ -1424,7 +1427,7 @@ func startCollectingMetrics(tCtx ktesting.TContext, collectorWG *sync.WaitGroup,
14241427
collector := collector
14251428
err := collector.init()
14261429
if err != nil {
1427-
return nil, nil, fmt.Errorf("op %d: Failed to initialize data collector: %v", opIndex, err)
1430+
return nil, nil, fmt.Errorf("op %d: Failed to initialize data collector: %w", opIndex, err)
14281431
}
14291432
tCtx.TB().Cleanup(func() {
14301433
collectorCtx.Cancel("cleaning up")
@@ -1519,7 +1522,7 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact
15191522
for opIndex, op := range unrollWorkloadTemplate(tCtx, tc.WorkloadTemplate, w) {
15201523
realOp, err := op.realOp.patchParams(w)
15211524
if err != nil {
1522-
return nil, fmt.Errorf("op %d: %v", opIndex, err)
1525+
return nil, fmt.Errorf("op %d: %w", opIndex, err)
15231526
}
15241527
select {
15251528
case <-tCtx.Done():
@@ -1528,14 +1531,14 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact
15281531
}
15291532
err = executor.runOp(realOp, opIndex)
15301533
if err != nil {
1531-
return nil, fmt.Errorf("op %d: %v", opIndex, err)
1534+
return nil, fmt.Errorf("op %d: %w", opIndex, err)
15321535
}
15331536
}
15341537

15351538
// check unused params and inform users
15361539
unusedParams := w.unusedParams()
15371540
if len(unusedParams) != 0 {
1538-
return nil, fmt.Errorf("the parameters %v are defined on workload %s, but unused.\nPlease make sure there are no typos.", unusedParams, w.Name)
1541+
return nil, fmt.Errorf("the parameters %v are defined on workload %s, but unused.\nPlease make sure there are no typos", unusedParams, w.Name)
15391542
}
15401543

15411544
// Some tests have unschedulable pods. Do not add an implicit barrier at the
@@ -1571,10 +1574,10 @@ func (e *WorkloadExecutor) runOp(op realOp, opIndex int) error {
15711574
func (e *WorkloadExecutor) runCreateNodesOp(opIndex int, op *createNodesOp) error {
15721575
nodePreparer, err := getNodePreparer(fmt.Sprintf("node-%d-", opIndex), op, e.tCtx.Client())
15731576
if err != nil {
1574-
return fmt.Errorf("op %d: %v", opIndex, err)
1577+
return fmt.Errorf("op %d: %w", opIndex, err)
15751578
}
15761579
if err := nodePreparer.PrepareNodes(e.tCtx, e.nextNodeIndex); err != nil {
1577-
return fmt.Errorf("op %d: %v", opIndex, err)
1580+
return fmt.Errorf("op %d: %w", opIndex, err)
15781581
}
15791582
e.nextNodeIndex += op.Count
15801583
return nil
@@ -1583,14 +1586,14 @@ func (e *WorkloadExecutor) runCreateNodesOp(opIndex int, op *createNodesOp) erro
15831586
func (e *WorkloadExecutor) runCreateNamespaceOp(opIndex int, op *createNamespacesOp) error {
15841587
nsPreparer, err := newNamespacePreparer(e.tCtx, op)
15851588
if err != nil {
1586-
return fmt.Errorf("op %d: %v", opIndex, err)
1589+
return fmt.Errorf("op %d: %w", opIndex, err)
15871590
}
15881591
if err := nsPreparer.prepare(e.tCtx); err != nil {
15891592
err2 := nsPreparer.cleanup(e.tCtx)
15901593
if err2 != nil {
15911594
err = fmt.Errorf("prepare: %w; cleanup: %w", err, err2)
15921595
}
1593-
return fmt.Errorf("op %d: %v", opIndex, err)
1596+
return fmt.Errorf("op %d: %w", opIndex, err)
15941597
}
15951598
for _, n := range nsPreparer.namespaces() {
15961599
if _, ok := e.numPodsScheduledPerNamespace[n]; ok {
@@ -1611,14 +1614,14 @@ func (e *WorkloadExecutor) runBarrierOp(opIndex int, op *barrierOp) error {
16111614
switch op.StageRequirement {
16121615
case Attempted:
16131616
if err := waitUntilPodsAttempted(e.tCtx, e.podInformer, op.LabelSelector, op.Namespaces, e.numPodsScheduledPerNamespace); err != nil {
1614-
return fmt.Errorf("op %d: %v", opIndex, err)
1617+
return fmt.Errorf("op %d: %w", opIndex, err)
16151618
}
16161619
case Scheduled:
16171620
// Default should be treated like "Scheduled", so handling both in the same way.
16181621
fallthrough
16191622
default:
16201623
if err := waitUntilPodsScheduled(e.tCtx, e.podInformer, op.LabelSelector, op.Namespaces, e.numPodsScheduledPerNamespace); err != nil {
1621-
return fmt.Errorf("op %d: %v", opIndex, err)
1624+
return fmt.Errorf("op %d: %w", opIndex, err)
16221625
}
16231626
// At the end of the barrier, we can be sure that there are no pods
16241627
// pending scheduling in the namespaces that we just blocked on.
@@ -1657,7 +1660,10 @@ func (e *WorkloadExecutor) runCreatePodsOp(opIndex int, op *createPodsOp) error
16571660
if op.Namespace != nil {
16581661
namespace = *op.Namespace
16591662
}
1660-
createNamespaceIfNotPresent(e.tCtx, namespace, &e.numPodsScheduledPerNamespace)
1663+
err := createNamespaceIfNotPresent(e.tCtx, namespace, &e.numPodsScheduledPerNamespace)
1664+
if err != nil {
1665+
return err
1666+
}
16611667
if op.PodTemplatePath == nil {
16621668
op.PodTemplatePath = e.testCase.DefaultPodTemplatePath
16631669
}
@@ -1673,7 +1679,7 @@ func (e *WorkloadExecutor) runCreatePodsOp(opIndex int, op *createPodsOp) error
16731679
}
16741680
}
16751681
if err := createPodsRapidly(e.tCtx, namespace, op); err != nil {
1676-
return fmt.Errorf("op %d: %v", opIndex, err)
1682+
return fmt.Errorf("op %d: %w", opIndex, err)
16771683
}
16781684
switch {
16791685
case op.SkipWaitToCompletion:
@@ -1682,11 +1688,11 @@ func (e *WorkloadExecutor) runCreatePodsOp(opIndex int, op *createPodsOp) error
16821688
e.numPodsScheduledPerNamespace[namespace] += op.Count
16831689
case op.SteadyState:
16841690
if err := createPodsSteadily(e.tCtx, namespace, e.podInformer, op); err != nil {
1685-
return fmt.Errorf("op %d: %v", opIndex, err)
1691+
return fmt.Errorf("op %d: %w", opIndex, err)
16861692
}
16871693
default:
16881694
if err := waitUntilPodsScheduledInNamespace(e.tCtx, e.podInformer, nil, namespace, op.Count); err != nil {
1689-
return fmt.Errorf("op %d: error in waiting for pods to get scheduled: %v", opIndex, err)
1695+
return fmt.Errorf("op %d: error in waiting for pods to get scheduled: %w", opIndex, err)
16901696
}
16911697
}
16921698
if op.CollectMetrics {
@@ -1708,7 +1714,7 @@ func (e *WorkloadExecutor) runDeletePodsOp(opIndex int, op *deletePodsOp) error
17081714

17091715
podsToDelete, err := e.podInformer.Lister().Pods(op.Namespace).List(labelSelector)
17101716
if err != nil {
1711-
return fmt.Errorf("op %d: error in listing pods in the namespace %s: %v", opIndex, op.Namespace, err)
1717+
return fmt.Errorf("op %d: error in listing pods in the namespace %s: %w", opIndex, op.Namespace, err)
17121718
}
17131719

17141720
deletePods := func(opIndex int) {
@@ -1765,20 +1771,20 @@ func (e *WorkloadExecutor) runChurnOp(opIndex int, op *churnOp) error {
17651771
// Ensure the namespace exists.
17661772
nsObj := &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}}
17671773
if _, err := e.tCtx.Client().CoreV1().Namespaces().Create(e.tCtx, nsObj, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) {
1768-
return fmt.Errorf("op %d: unable to create namespace %v: %v", opIndex, namespace, err)
1774+
return fmt.Errorf("op %d: unable to create namespace %v: %w", opIndex, namespace, err)
17691775
}
17701776

17711777
var churnFns []func(name string) string
17721778

17731779
for i, path := range op.TemplatePaths {
17741780
unstructuredObj, gvk, err := getUnstructuredFromFile(path)
17751781
if err != nil {
1776-
return fmt.Errorf("op %d: unable to parse the %v-th template path: %v", opIndex, i, err)
1782+
return fmt.Errorf("op %d: unable to parse the %v-th template path: %w", opIndex, i, err)
17771783
}
17781784
// Obtain GVR.
17791785
mapping, err := restMapper.RESTMapping(gvk.GroupKind(), gvk.Version)
17801786
if err != nil {
1781-
return fmt.Errorf("op %d: unable to find GVR for %v: %v", opIndex, gvk, err)
1787+
return fmt.Errorf("op %d: unable to find GVR for %v: %w", opIndex, gvk, err)
17821788
}
17831789
gvr := mapping.Resource
17841790
// Distinguish cluster-scoped with namespaced API objects.
@@ -1867,7 +1873,10 @@ func (e *WorkloadExecutor) runDefaultOp(opIndex int, op realOp) error {
18671873
return fmt.Errorf("op %d: invalid op %v", opIndex, op)
18681874
}
18691875
for _, namespace := range runable.requiredNamespaces() {
1870-
createNamespaceIfNotPresent(e.tCtx, namespace, &e.numPodsScheduledPerNamespace)
1876+
err := createNamespaceIfNotPresent(e.tCtx, namespace, &e.numPodsScheduledPerNamespace)
1877+
if err != nil {
1878+
return err
1879+
}
18711880
}
18721881
runable.run(e.tCtx)
18731882
return nil

0 commit comments

Comments
 (0)