Skip to content

Commit abfbb95

Browse files
authored
[supervisor] Drop feature flag supervisor_terminal_no_deadline_exceeded (#20869)
1 parent 28be342 commit abfbb95

File tree

4 files changed

+8
-62
lines changed

4 files changed

+8
-62
lines changed

components/supervisor/pkg/supervisor/supervisor.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"strconv"
3030
"strings"
3131
"sync"
32-
"sync/atomic"
3332
"syscall"
3433
"time"
3534

@@ -337,10 +336,9 @@ func Run(options ...RunOption) {
337336
}
338337
}
339338

340-
terminalNoDeadlineExceeded := watchTerminalNoDeadlineExceeded(ctx, exps, host)
341339
willShutdownCtx, fireWillShutdown := context.WithCancel(ctx)
342340
termMux := terminal.NewMux()
343-
termMuxSrv := terminal.NewMuxTerminalService(termMux, terminalNoDeadlineExceeded)
341+
termMuxSrv := terminal.NewMuxTerminalService(termMux)
344342
termMuxSrv.DefaultWorkdir = cfg.RepoRoot
345343
if cfg.WorkspaceRoot != "" {
346344
termMuxSrv.DefaultWorkdirProvider = func() string {
@@ -584,36 +582,6 @@ func getIDENotReadyShutdownDuration(ctx context.Context, exps experiments.Client
584582
}
585583
}
586584

587-
func watchTerminalNoDeadlineExceeded(ctx context.Context, exps experiments.Client, gitpodHost string) *atomic.Bool {
588-
newBool := func(v bool) *atomic.Bool {
589-
r := atomic.Bool{}
590-
r.Store(v)
591-
return &r
592-
}
593-
if exps == nil {
594-
return newBool(false)
595-
}
596-
597-
value := exps.GetBoolValue(ctx, "supervisor_terminal_no_deadline_exceeded", false, experiments.Attributes{GitpodHost: gitpodHost})
598-
result := newBool(value)
599-
600-
go (func() {
601-
t := time.NewTicker(30 * time.Second)
602-
603-
for {
604-
select {
605-
case <-ctx.Done():
606-
return
607-
case <-t.C:
608-
value := exps.GetBoolValue(ctx, "supervisor_terminal_no_deadline_exceeded", false, experiments.Attributes{GitpodHost: gitpodHost})
609-
result.Store(value)
610-
}
611-
}
612-
})()
613-
614-
return result
615-
}
616-
617585
func isShallowRepository(rootDir string) bool {
618586
cmd := runAsGitpodUser(exec.Command("git", "rev-parse", "--is-shallow-repository"))
619587
cmd.Dir = rootDir

components/supervisor/pkg/supervisor/tasks_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111
"strconv"
1212
"sync"
13-
"sync/atomic"
1413
"testing"
1514

1615
"github.com/google/go-cmp/cmp"
@@ -22,12 +21,6 @@ import (
2221
"github.com/gitpod-io/gitpod/supervisor/pkg/terminal"
2322
)
2423

25-
func newBool(b bool) *atomic.Bool {
26-
result := atomic.Bool{}
27-
result.Store(b)
28-
return &result
29-
}
30-
3124
var (
3225
skipCommand = "echo \"skip\""
3326
failCommand = "exit 1"
@@ -223,7 +216,7 @@ func TestTaskManager(t *testing.T) {
223216
}
224217

225218
var (
226-
terminalService = terminal.NewMuxTerminalService(terminal.NewMux(), newBool(true))
219+
terminalService = terminal.NewMuxTerminalService(terminal.NewMux())
227220
contentState = NewInMemoryContentState("")
228221
reporter = testHeadlessTaskProgressReporter{}
229222
taskManager = newTasksManager(&Config{

components/supervisor/pkg/terminal/service.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"os"
1212
"os/exec"
1313
"path/filepath"
14-
"sync/atomic"
1514
"syscall"
1615
"time"
1716

@@ -27,7 +26,7 @@ import (
2726
)
2827

2928
// NewMuxTerminalService creates a new terminal service.
30-
func NewMuxTerminalService(m *Mux, terminalNoDeadlineExceeded *atomic.Bool) *MuxTerminalService {
29+
func NewMuxTerminalService(m *Mux) *MuxTerminalService {
3130
shell := os.Getenv("SHELL")
3231
if shell == "" {
3332
shell = "/bin/bash"
@@ -37,8 +36,6 @@ func NewMuxTerminalService(m *Mux, terminalNoDeadlineExceeded *atomic.Bool) *Mux
3736
DefaultWorkdir: "/workspace",
3837
DefaultShell: shell,
3938
Env: os.Environ(),
40-
41-
terminalNoDeadlineExceeded: terminalNoDeadlineExceeded,
4239
}
4340
}
4441

@@ -56,8 +53,6 @@ type MuxTerminalService struct {
5653
DefaultCreds *syscall.Credential
5754
DefaultAmbientCaps []uintptr
5855

59-
terminalNoDeadlineExceeded *atomic.Bool
60-
6156
api.UnimplementedTerminalServiceServer
6257
}
6358

@@ -291,10 +286,7 @@ func (srv *MuxTerminalService) Listen(req *api.ListenTerminalRequest, resp api.T
291286
err = resp.Send(message)
292287
case err = <-errchan:
293288
case <-resp.Context().Done():
294-
if srv.terminalNoDeadlineExceeded.Load() {
295-
return nil
296-
}
297-
return status.Error(codes.DeadlineExceeded, resp.Context().Err().Error())
289+
return nil
298290
}
299291
if err == io.EOF {
300292
// EOF isn't really an error here

components/supervisor/pkg/terminal/terminal_test.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"os"
1212
"os/exec"
1313
"strings"
14-
"sync/atomic"
1514
"testing"
1615
"time"
1716

@@ -22,12 +21,6 @@ import (
2221
"github.com/gitpod-io/gitpod/supervisor/api"
2322
)
2423

25-
func newBool(b bool) *atomic.Bool {
26-
result := atomic.Bool{}
27-
result.Store(b)
28-
return &result
29-
}
30-
3124
func TestTitle(t *testing.T) {
3225
t.Skip("skipping flakey tests")
3326

@@ -66,7 +59,7 @@ func TestTitle(t *testing.T) {
6659
}
6760
defer os.RemoveAll(tmpWorkdir)
6861

69-
terminalService := NewMuxTerminalService(mux, newBool(true))
62+
terminalService := NewMuxTerminalService(mux)
7063
terminalService.DefaultWorkdir = tmpWorkdir
7164

7265
term, err := terminalService.OpenWithOptions(ctx, &api.OpenTerminalRequest{}, TermOptions{
@@ -204,7 +197,7 @@ func TestAnnotations(t *testing.T) {
204197
mux := NewMux()
205198
defer mux.Close(ctx)
206199

207-
terminalService := NewMuxTerminalService(mux, newBool(true))
200+
terminalService := NewMuxTerminalService(mux)
208201
var err error
209202
if test.Opts == nil {
210203
_, err = terminalService.Open(ctx, test.Req)
@@ -255,7 +248,7 @@ func TestTerminals(t *testing.T) {
255248
}
256249
for _, test := range tests {
257250
t.Run(test.Desc, func(t *testing.T) {
258-
terminalService := NewMuxTerminalService(NewMux(), newBool(true))
251+
terminalService := NewMuxTerminalService(NewMux())
259252
resp, err := terminalService.Open(context.Background(), &api.OpenTerminalRequest{})
260253
if err != nil {
261254
t.Fatal(err)
@@ -336,7 +329,7 @@ func TestWorkDirProvider(t *testing.T) {
336329
mux := NewMux()
337330
defer mux.Close(ctx)
338331

339-
terminalService := NewMuxTerminalService(mux, newBool(true))
332+
terminalService := NewMuxTerminalService(mux)
340333

341334
type AssertWorkDirTest struct {
342335
expectedWorkDir string

0 commit comments

Comments
 (0)