Skip to content

Commit fa7042f

Browse files
committed
remove error return from Stop() (nothing to really do about it, the controllers must make best effort to clean up)
1 parent b3f229b commit fa7042f

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

pkg/blockcontroller/blockcontroller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type BlockControllerRuntimeStatus struct {
6565
// Controller interface that all block controllers must implement
6666
type Controller interface {
6767
Start(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error
68-
Stop(graceful bool, newStatus string, destroy bool) error
68+
Stop(graceful bool, newStatus string, destroy bool)
6969
GetRuntimeStatus() *BlockControllerRuntimeStatus // does not return nil
7070
SendInput(input *BlockInputUnion) error
7171
}

pkg/blockcontroller/shellcontroller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (sc *ShellController) Start(ctx context.Context, blockMeta waveobj.MetaMapT
9393
return nil
9494
}
9595

96-
func (sc *ShellController) Stop(graceful bool, newStatus string, destroy bool) error {
96+
func (sc *ShellController) Stop(graceful bool, newStatus string, destroy bool) {
9797
sc.Lock.Lock()
9898
defer sc.Lock.Unlock()
9999

@@ -102,7 +102,7 @@ func (sc *ShellController) Stop(graceful bool, newStatus string, destroy bool) e
102102
sc.ProcStatus = newStatus
103103
sc.sendUpdate_nolock()
104104
}
105-
return nil
105+
return
106106
}
107107

108108
sc.ShellProc.Close()
@@ -116,7 +116,6 @@ func (sc *ShellController) Stop(graceful bool, newStatus string, destroy bool) e
116116
// Update status
117117
sc.ProcStatus = newStatus
118118
sc.sendUpdate_nolock()
119-
return nil
120119
}
121120

122121
func (sc *ShellController) getRuntimeStatus_nolock() BlockControllerRuntimeStatus {

pkg/blockcontroller/shelljobcontroller.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"io/fs"
1111
"log"
1212
"sync"
13+
"time"
1314

1415
"github.com/google/uuid"
1516
"github.com/wavetermdev/waveterm/pkg/blocklogger"
@@ -188,17 +189,21 @@ func (sjc *ShellJobController) Start(ctx context.Context, blockMeta waveobj.Meta
188189
return nil
189190
}
190191

191-
func (sjc *ShellJobController) Stop(graceful bool, newStatus string, destroy bool) error {
192+
func (sjc *ShellJobController) Stop(graceful bool, newStatus string, destroy bool) {
192193
if !destroy {
193-
return nil
194+
return
194195
}
195196
jobId := sjc.getJobId()
196197
if jobId == "" {
197-
return nil
198+
return
198199
}
199-
ctx := context.Background()
200+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
201+
defer cancel()
200202
jobcontroller.DetachJobFromBlock(ctx, jobId, false)
201-
return jobcontroller.TerminateJobManager(ctx, jobId)
203+
err := jobcontroller.TerminateJobManager(ctx, jobId)
204+
if err != nil {
205+
log.Printf("error terminating job manager: %v\n", err)
206+
}
202207
}
203208

204209
func (sjc *ShellJobController) SendInput(inputUnion *BlockInputUnion) error {

pkg/blockcontroller/tsunamicontroller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ func (c *TsunamiController) Start(ctx context.Context, blockMeta waveobj.MetaMap
235235
return nil
236236
}
237237

238-
func (c *TsunamiController) Stop(graceful bool, newStatus string, destroy bool) error {
238+
func (c *TsunamiController) Stop(graceful bool, newStatus string, destroy bool) {
239239
log.Printf("TsunamiController.Stop called for block %s (graceful: %t, newStatus: %s)", c.blockId, graceful, newStatus)
240240
c.runLock.Lock()
241241
defer c.runLock.Unlock()
242242

243243
if c.tsunamiProc == nil {
244-
return nil
244+
return
245245
}
246246

247247
if c.tsunamiProc.Cmd.Process != nil {
@@ -262,7 +262,6 @@ func (c *TsunamiController) Stop(graceful bool, newStatus string, destroy bool)
262262
})
263263
c.clearSchemas()
264264
go c.sendStatusUpdate()
265-
return nil
266265
}
267266

268267
func (c *TsunamiController) GetRuntimeStatus() *BlockControllerRuntimeStatus {

pkg/jobcontroller/jobcontroller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ func tryTerminateJobManager(ctx context.Context, jobId string) {
466466
}
467467

468468
func TerminateJobManager(ctx context.Context, jobId string) error {
469-
err := wstore.DBUpdateFn[*waveobj.Job](ctx, jobId, func(job *waveobj.Job) {
469+
err := wstore.DBUpdateFn(ctx, jobId, func(job *waveobj.Job) {
470470
job.TerminateOnReconnect = true
471471
})
472472
if err != nil {

0 commit comments

Comments
 (0)