Skip to content

Commit 11b808a

Browse files
Fix errcheck in ./host/ (#3741)
1 parent b2c5357 commit 11b808a

10 files changed

+68
-59
lines changed

host/cancel_workflow_test.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,17 @@ func (s *integrationSuite) TestImmediateChildCancellation_WorkflowTaskFailed() {
513513
s.NoError(err0)
514514
s.Logger.Info("StartWorkflowExecution", tag.WorkflowRunID(we.RunId))
515515

516-
s.engine.RequestCancelWorkflowExecution(NewContext(), &workflowservice.RequestCancelWorkflowExecutionRequest{
517-
Namespace: s.namespace,
518-
WorkflowExecution: &commonpb.WorkflowExecution{
519-
WorkflowId: id,
520-
RunId: we.RunId,
521-
},
522-
Identity: identity,
523-
RequestId: uuid.New(),
524-
})
516+
_, err := s.engine.RequestCancelWorkflowExecution(NewContext(),
517+
&workflowservice.RequestCancelWorkflowExecutionRequest{
518+
Namespace: s.namespace,
519+
WorkflowExecution: &commonpb.WorkflowExecution{
520+
WorkflowId: id,
521+
RunId: we.RunId,
522+
},
523+
Identity: identity,
524+
RequestId: uuid.New(),
525+
})
526+
s.NoError(err)
525527

526528
childCancelled := false
527529
var initiatedEvent *historypb.HistoryEvent
@@ -620,7 +622,7 @@ func (s *integrationSuite) TestImmediateChildCancellation_WorkflowTaskFailed() {
620622
}
621623

622624
s.Logger.Info("Process first workflow task which starts and request cancels child workflow")
623-
_, err := poller.PollAndProcessWorkflowTask(false, false)
625+
_, err = poller.PollAndProcessWorkflowTask(false, false)
624626
s.Error(err)
625627
s.IsType(&serviceerror.InvalidArgument{}, err)
626628
s.Equal("BadRequestCancelExternalWorkflowExecutionAttributes: Start and RequestCancel for child workflow is not allowed in same workflow task.", err.Error())

host/client_integration_test.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,11 @@ func (s *clientIntegrationSuite) Test_StickyWorkerRestartWorkflowTask() {
884884
for _, tt := range testCases {
885885
s.Run(tt.name, func() {
886886
workflowFn := func(ctx workflow.Context) (string, error) {
887-
workflow.SetQueryHandler(ctx, "test", func() (string, error) {
887+
if err := workflow.SetQueryHandler(ctx, "test", func() (string, error) {
888888
return "query works", nil
889-
})
889+
}); err != nil {
890+
return "", err
891+
}
890892

891893
signalCh := workflow.GetSignalChannel(ctx, "test")
892894
var msg string
@@ -1293,9 +1295,11 @@ func (s *clientIntegrationSuite) Test_BufferedQuery() {
12931295
workflowFn := func(ctx workflow.Context) error {
12941296
wfStarted.Done()
12951297
status := "init"
1296-
workflow.SetQueryHandler(ctx, "foo", func() (string, error) {
1298+
if err := workflow.SetQueryHandler(ctx, "foo", func() (string, error) {
12971299
return status, nil
1298-
})
1300+
}); err != nil {
1301+
return err
1302+
}
12991303
ctx1 := workflow.WithLocalActivityOptions(ctx, workflow.LocalActivityOptions{
13001304
ScheduleToCloseTimeout: 10 * time.Second,
13011305
})
@@ -1305,9 +1309,7 @@ func (s *clientIntegrationSuite) Test_BufferedQuery() {
13051309
err1 := f1.Get(ctx1, nil)
13061310
status = "done"
13071311

1308-
workflow.Sleep(ctx, 5*time.Second)
1309-
1310-
return err1
1312+
return multierr.Combine(err1, workflow.Sleep(ctx, 5*time.Second))
13111313
}
13121314

13131315
s.worker.RegisterWorkflow(workflowFn)
@@ -1335,13 +1337,14 @@ func (s *clientIntegrationSuite) Test_BufferedQuery() {
13351337
// sleep 2s to make sure DescribeMutableState is called after QueryWorkflow
13361338
time.Sleep(2 * time.Second)
13371339
// make DescribeMutableState call, which force mutable state to reload from db
1338-
s.adminClient.DescribeMutableState(ctx, &adminservice.DescribeMutableStateRequest{
1340+
_, err := s.adminClient.DescribeMutableState(ctx, &adminservice.DescribeMutableStateRequest{
13391341
Namespace: s.namespace,
13401342
Execution: &commonpb.WorkflowExecution{
13411343
WorkflowId: id,
13421344
RunId: workflowRun.GetRunID(),
13431345
},
13441346
})
1347+
s.Assert().NoError(err)
13451348
}()
13461349

13471350
// this query will be buffered in mutable state because workflow task is in-flight.

host/cron_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ func (s *clientIntegrationSuite) TestCronWorkflowCompletionStates() {
410410
s.Equal(lcr, "pass")
411411
s.NotNil(workflow.GetLastError(ctx))
412412
s.Equal(workflow.GetLastError(ctx).Error(), "second error")
413-
workflow.Sleep(ctx, 10*time.Second) // cause wft timeout
413+
s.NoError(workflow.Sleep(ctx, 10*time.Second)) // cause wft timeout
414414
panic("should have been timed out on server already")
415415

416416
case 4:

host/gethistory_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ func (s *clientIntegrationSuite) TestGetHistoryReverse_MultipleBranches() {
701701
err1 = f1.Get(ctx1, nil)
702702
s.NoError(err1)
703703

704-
workflow.Sleep(ctx, time.Second*2)
704+
s.NoError(workflow.Sleep(ctx, time.Second*2))
705705

706706
f2 := workflow.ExecuteActivity(ctx1, activityFn)
707707
err2 = f2.Get(ctx1, nil)

host/max_buffered_event_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ func (s *clientIntegrationSuite) TestMaxBufferedEventsLimit() {
6464
RetryPolicy: &temporal.RetryPolicy{MaximumAttempts: 1},
6565
})
6666
f1 := workflow.ExecuteLocalActivity(ctx1, localActivityFn)
67-
f1.Get(ctx, nil)
67+
if err := f1.Get(ctx, nil); err != nil {
68+
return 0, err
69+
}
6870

6971
sigCh := workflow.GetSignalChannel(ctx, "test-signal")
7072

host/onebox.go

+21-24
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ package host
2727
import (
2828
"context"
2929
"encoding/json"
30-
"errors"
3130
"fmt"
3231
"net"
33-
"strings"
3432
"sync"
3533
"time"
3634

3735
"go.uber.org/fx"
36+
"go.uber.org/multierr"
3837
"golang.org/x/exp/maps"
3938
"google.golang.org/grpc"
4039

@@ -244,38 +243,28 @@ func (c *temporalImpl) Stop() error {
244243
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
245244
defer cancel()
246245

247-
var errs []string
246+
var errs error
248247

249248
if c.enableWorker() {
250249
c.shutdownWG.Add(1)
251-
err := c.workerApp.Stop(ctx)
252-
if err != nil {
253-
errs = append(errs, err.Error())
254-
}
250+
errs = multierr.Combine(errs, c.workerApp.Stop(ctx))
255251
}
256252

257253
c.shutdownWG.Add(3)
258254

259-
c.frontendApp.Stop(ctx)
255+
if err := c.frontendApp.Stop(ctx); err != nil {
256+
return err
257+
}
260258
for _, historyApp := range c.historyApps {
261-
err := historyApp.Stop(ctx)
262-
if err != nil {
263-
errs = append(errs, err.Error())
264-
}
259+
errs = multierr.Combine(errs, historyApp.Stop(ctx))
265260
}
266261

267-
err := c.matchingApp.Stop(ctx)
268-
if err != nil {
269-
errs = append(errs, err.Error())
270-
}
262+
errs = multierr.Combine(errs, c.matchingApp.Stop(ctx))
271263

272264
close(c.shutdownCh)
273265
c.shutdownWG.Wait()
274266

275-
if len(errs) > 0 {
276-
return errors.New("shutdown errors: " + strings.Join(errs, "; "))
277-
}
278-
return nil
267+
return errs
279268
}
280269

281270
func (c *temporalImpl) FrontendGRPCAddress() string {
@@ -443,7 +432,9 @@ func (c *temporalImpl) startFrontend(hosts map[primitives.ServiceName][]string,
443432
c.adminClient = NewAdminClient(connection)
444433
c.operatorClient = operatorservice.NewOperatorServiceClient(connection)
445434

446-
feApp.Start(context.Background())
435+
if err := feApp.Start(context.Background()); err != nil {
436+
c.logger.Fatal("unable to start frontend service", tag.Error(err))
437+
}
447438

448439
startWG.Done()
449440
<-c.shutdownCh
@@ -537,7 +528,9 @@ func (c *temporalImpl) startHistory(
537528
c.historyServices = append(c.historyServices, historyService)
538529
c.historyNamespaceRegistries = append(c.historyNamespaceRegistries, namespaceRegistry)
539530

540-
app.Start(context.Background())
531+
if err := app.Start(context.Background()); err != nil {
532+
c.logger.Fatal("unable to start history service", tag.Error(err))
533+
}
541534
}
542535

543536
startWG.Done()
@@ -600,7 +593,9 @@ func (c *temporalImpl) startMatching(hosts map[primitives.ServiceName][]string,
600593
c.matchingApp = app
601594
c.matchingService = matchingService
602595
c.matchingNamespaceRegistry = namespaceRegistry
603-
app.Start(context.Background())
596+
if err := app.Start(context.Background()); err != nil {
597+
c.logger.Fatal("unable to start matching service", tag.Error(err))
598+
}
604599

605600
startWG.Done()
606601
<-c.shutdownCh
@@ -679,7 +674,9 @@ func (c *temporalImpl) startWorker(hosts map[primitives.ServiceName][]string, st
679674
c.workerApp = app
680675
c.workerService = workerService
681676
c.workerNamespaceRegistry = namespaceRegistry
682-
app.Start(context.Background())
677+
if err := app.Start(context.Background()); err != nil {
678+
c.logger.Fatal("unable to start worker service", tag.Error(err))
679+
}
683680

684681
startWG.Done()
685682
<-c.shutdownCh

host/schedule_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ func (s *scheduleIntegrationSuite) TestRefresh() {
508508
atomic.AddInt32(&runs, 1)
509509
return 0
510510
})
511-
workflow.Sleep(ctx, 10*time.Second) // longer than execution timeout
511+
s.NoError(workflow.Sleep(ctx, 10*time.Second)) // longer than execution timeout
512512
return nil
513513
}
514514
s.worker.RegisterWorkflowWithOptions(workflowFn, workflow.RegisterOptions{Name: wt})

host/test_cluster.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
"github.com/pborman/uuid"
3333
"go.temporal.io/api/operatorservice/v1"
34+
"go.uber.org/multierr"
3435

3536
"go.temporal.io/server/api/adminservice/v1"
3637
persistencespb "go.temporal.io/server/api/persistence/v1"
@@ -309,12 +310,16 @@ func (tc *TestCluster) SetFaultInjectionRate(rate float64) {
309310
// TearDownCluster tears down the test cluster
310311
func (tc *TestCluster) TearDownCluster() error {
311312
tc.SetFaultInjectionRate(0)
312-
err := tc.host.Stop()
313+
errs := tc.host.Stop()
313314
tc.host = nil
314315
tc.testBase.TearDownWorkflowStore()
315-
os.RemoveAll(tc.archiverBase.historyStoreDirectory)
316-
os.RemoveAll(tc.archiverBase.visibilityStoreDirectory)
317-
return err
316+
if err := os.RemoveAll(tc.archiverBase.historyStoreDirectory); err != nil {
317+
errs = multierr.Combine(errs, err)
318+
}
319+
if err := os.RemoveAll(tc.archiverBase.visibilityStoreDirectory); err != nil {
320+
errs = multierr.Combine(errs, err)
321+
}
322+
return errs
318323
}
319324

320325
// GetFrontendClient returns a frontend client from the test cluster

host/workflow_failures_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ func (s *integrationSuite) TestWorkflowTaskFailed() {
181181

182182
// Send signals during workflow task
183183
if sendSignal {
184-
s.sendSignal(s.namespace, workflowExecution, "signalC", nil, identity)
185-
s.sendSignal(s.namespace, workflowExecution, "signalD", nil, identity)
186-
s.sendSignal(s.namespace, workflowExecution, "signalE", nil, identity)
184+
s.NoError(s.sendSignal(s.namespace, workflowExecution, "signalC", nil, identity))
185+
s.NoError(s.sendSignal(s.namespace, workflowExecution, "signalD", nil, identity))
186+
s.NoError(s.sendSignal(s.namespace, workflowExecution, "signalE", nil, identity))
187187
sendSignal = false
188188
}
189189

host/xdc/integration_failover_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@ func (s *integrationClustersTestSuite) TestActivityHeartbeatFailover() {
18991899
}
19001900
worker1.RegisterWorkflow(testWorkflowFn)
19011901
worker1.RegisterActivity(activityWithHB)
1902-
worker1.Start()
1902+
s.NoError(worker1.Start())
19031903

19041904
// Start a workflow
19051905
startTime := time.Now()
@@ -1954,7 +1954,7 @@ func (s *integrationClustersTestSuite) TestActivityHeartbeatFailover() {
19541954
// start worker2
19551955
worker2.RegisterWorkflow(testWorkflowFn)
19561956
worker2.RegisterActivity(activityWithHB)
1957-
worker2.Start()
1957+
s.NoError(worker2.Start())
19581958
defer worker2.Stop()
19591959

19601960
// ExecuteWorkflow return existing running workflow if it already started
@@ -1998,7 +1998,7 @@ func (s *integrationClustersTestSuite) TestLocalNamespaceMigration() {
19981998
}
19991999

20002000
worker1.RegisterWorkflow(testWorkflowFn)
2001-
worker1.Start()
2001+
s.NoError(worker1.Start())
20022002

20032003
// Start wf1 (in local ns)
20042004
workflowID := "local-ns-wf-1"
@@ -2353,7 +2353,7 @@ func (s *integrationClustersTestSuite) TestForceMigration_ClosedWorkflow() {
23532353
}
23542354

23552355
worker1.RegisterWorkflow(testWorkflowFn)
2356-
worker1.Start()
2356+
s.NoError(worker1.Start())
23572357

23582358
// Start wf1
23592359
workflowID := "force-replication-test-wf-1"
@@ -2438,7 +2438,7 @@ func (s *integrationClustersTestSuite) TestForceMigration_ClosedWorkflow() {
24382438
s.Equal(clusterName[1], nsResp.ReplicationConfig.ActiveClusterName)
24392439

24402440
worker2.RegisterWorkflow(testWorkflowFn)
2441-
worker2.Start()
2441+
s.NoError(worker2.Start())
24422442

24432443
// Test reset workflow in cluster 2
24442444
resetResp, err := client2.ResetWorkflowExecution(testCtx, &workflowservice.ResetWorkflowExecutionRequest{
@@ -2477,7 +2477,7 @@ func (s *integrationClustersTestSuite) TestForceMigration_ResetWorkflow() {
24772477
}
24782478

24792479
worker1.RegisterWorkflow(testWorkflowFn)
2480-
worker1.Start()
2480+
s.NoError(worker1.Start())
24812481

24822482
// Start wf1
24832483
workflowID := "force-replication-test-reset-wf-1"

0 commit comments

Comments
 (0)