@@ -1196,7 +1196,7 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
1196
1196
1197
1197
results , err := runWorkload (tCtx , tc , w , informerFactory )
1198
1198
if err != nil {
1199
- tCtx .Fatalf ("%w : %s" , w .Name , err )
1199
+ tCtx .Fatalf ("Error running workload %s : %s" , w .Name , err )
1200
1200
}
1201
1201
dataItems .DataItems = append (dataItems .DataItems , results ... )
1202
1202
@@ -1295,7 +1295,10 @@ func RunIntegrationPerfScheduling(t *testing.T, configFile string) {
1295
1295
t .Fatalf ("workload %s is not valid: %v" , w .Name , err )
1296
1296
}
1297
1297
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
+ }
1299
1302
1300
1303
if featureGates [features .SchedulerQueueingHints ] {
1301
1304
// 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,
1424
1427
collector := collector
1425
1428
err := collector .init ()
1426
1429
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 )
1428
1431
}
1429
1432
tCtx .TB ().Cleanup (func () {
1430
1433
collectorCtx .Cancel ("cleaning up" )
@@ -1519,7 +1522,7 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact
1519
1522
for opIndex , op := range unrollWorkloadTemplate (tCtx , tc .WorkloadTemplate , w ) {
1520
1523
realOp , err := op .realOp .patchParams (w )
1521
1524
if err != nil {
1522
- return nil , fmt .Errorf ("op %d: %v " , opIndex , err )
1525
+ return nil , fmt .Errorf ("op %d: %w " , opIndex , err )
1523
1526
}
1524
1527
select {
1525
1528
case <- tCtx .Done ():
@@ -1528,14 +1531,14 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact
1528
1531
}
1529
1532
err = executor .runOp (realOp , opIndex )
1530
1533
if err != nil {
1531
- return nil , fmt .Errorf ("op %d: %v " , opIndex , err )
1534
+ return nil , fmt .Errorf ("op %d: %w " , opIndex , err )
1532
1535
}
1533
1536
}
1534
1537
1535
1538
// check unused params and inform users
1536
1539
unusedParams := w .unusedParams ()
1537
1540
if len (unusedParams ) != 0 {
1538
- return nil , fmt .Errorf ("the parameters %v are defined on workload %s, but unused.\n Please make sure there are no typos. " , unusedParams , w .Name )
1541
+ return nil , fmt .Errorf ("the parameters %v are defined on workload %s, but unused.\n Please make sure there are no typos" , unusedParams , w .Name )
1539
1542
}
1540
1543
1541
1544
// 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 {
1571
1574
func (e * WorkloadExecutor ) runCreateNodesOp (opIndex int , op * createNodesOp ) error {
1572
1575
nodePreparer , err := getNodePreparer (fmt .Sprintf ("node-%d-" , opIndex ), op , e .tCtx .Client ())
1573
1576
if err != nil {
1574
- return fmt .Errorf ("op %d: %v " , opIndex , err )
1577
+ return fmt .Errorf ("op %d: %w " , opIndex , err )
1575
1578
}
1576
1579
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 )
1578
1581
}
1579
1582
e .nextNodeIndex += op .Count
1580
1583
return nil
@@ -1583,14 +1586,14 @@ func (e *WorkloadExecutor) runCreateNodesOp(opIndex int, op *createNodesOp) erro
1583
1586
func (e * WorkloadExecutor ) runCreateNamespaceOp (opIndex int , op * createNamespacesOp ) error {
1584
1587
nsPreparer , err := newNamespacePreparer (e .tCtx , op )
1585
1588
if err != nil {
1586
- return fmt .Errorf ("op %d: %v " , opIndex , err )
1589
+ return fmt .Errorf ("op %d: %w " , opIndex , err )
1587
1590
}
1588
1591
if err := nsPreparer .prepare (e .tCtx ); err != nil {
1589
1592
err2 := nsPreparer .cleanup (e .tCtx )
1590
1593
if err2 != nil {
1591
1594
err = fmt .Errorf ("prepare: %w; cleanup: %w" , err , err2 )
1592
1595
}
1593
- return fmt .Errorf ("op %d: %v " , opIndex , err )
1596
+ return fmt .Errorf ("op %d: %w " , opIndex , err )
1594
1597
}
1595
1598
for _ , n := range nsPreparer .namespaces () {
1596
1599
if _ , ok := e .numPodsScheduledPerNamespace [n ]; ok {
@@ -1611,14 +1614,14 @@ func (e *WorkloadExecutor) runBarrierOp(opIndex int, op *barrierOp) error {
1611
1614
switch op .StageRequirement {
1612
1615
case Attempted :
1613
1616
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 )
1615
1618
}
1616
1619
case Scheduled :
1617
1620
// Default should be treated like "Scheduled", so handling both in the same way.
1618
1621
fallthrough
1619
1622
default :
1620
1623
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 )
1622
1625
}
1623
1626
// At the end of the barrier, we can be sure that there are no pods
1624
1627
// pending scheduling in the namespaces that we just blocked on.
@@ -1657,7 +1660,10 @@ func (e *WorkloadExecutor) runCreatePodsOp(opIndex int, op *createPodsOp) error
1657
1660
if op .Namespace != nil {
1658
1661
namespace = * op .Namespace
1659
1662
}
1660
- createNamespaceIfNotPresent (e .tCtx , namespace , & e .numPodsScheduledPerNamespace )
1663
+ err := createNamespaceIfNotPresent (e .tCtx , namespace , & e .numPodsScheduledPerNamespace )
1664
+ if err != nil {
1665
+ return err
1666
+ }
1661
1667
if op .PodTemplatePath == nil {
1662
1668
op .PodTemplatePath = e .testCase .DefaultPodTemplatePath
1663
1669
}
@@ -1673,7 +1679,7 @@ func (e *WorkloadExecutor) runCreatePodsOp(opIndex int, op *createPodsOp) error
1673
1679
}
1674
1680
}
1675
1681
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 )
1677
1683
}
1678
1684
switch {
1679
1685
case op .SkipWaitToCompletion :
@@ -1682,11 +1688,11 @@ func (e *WorkloadExecutor) runCreatePodsOp(opIndex int, op *createPodsOp) error
1682
1688
e .numPodsScheduledPerNamespace [namespace ] += op .Count
1683
1689
case op .SteadyState :
1684
1690
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 )
1686
1692
}
1687
1693
default :
1688
1694
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 )
1690
1696
}
1691
1697
}
1692
1698
if op .CollectMetrics {
@@ -1708,7 +1714,7 @@ func (e *WorkloadExecutor) runDeletePodsOp(opIndex int, op *deletePodsOp) error
1708
1714
1709
1715
podsToDelete , err := e .podInformer .Lister ().Pods (op .Namespace ).List (labelSelector )
1710
1716
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 )
1712
1718
}
1713
1719
1714
1720
deletePods := func (opIndex int ) {
@@ -1765,20 +1771,20 @@ func (e *WorkloadExecutor) runChurnOp(opIndex int, op *churnOp) error {
1765
1771
// Ensure the namespace exists.
1766
1772
nsObj := & v1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : namespace }}
1767
1773
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 )
1769
1775
}
1770
1776
1771
1777
var churnFns []func (name string ) string
1772
1778
1773
1779
for i , path := range op .TemplatePaths {
1774
1780
unstructuredObj , gvk , err := getUnstructuredFromFile (path )
1775
1781
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 )
1777
1783
}
1778
1784
// Obtain GVR.
1779
1785
mapping , err := restMapper .RESTMapping (gvk .GroupKind (), gvk .Version )
1780
1786
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 )
1782
1788
}
1783
1789
gvr := mapping .Resource
1784
1790
// Distinguish cluster-scoped with namespaced API objects.
@@ -1867,7 +1873,10 @@ func (e *WorkloadExecutor) runDefaultOp(opIndex int, op realOp) error {
1867
1873
return fmt .Errorf ("op %d: invalid op %v" , opIndex , op )
1868
1874
}
1869
1875
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
+ }
1871
1880
}
1872
1881
runable .run (e .tCtx )
1873
1882
return nil
0 commit comments