Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 1 addition & 33 deletions components/supervisor/pkg/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"strconv"
"strings"
"sync"
"sync/atomic"
"syscall"
"time"

Expand Down Expand Up @@ -337,10 +336,9 @@ func Run(options ...RunOption) {
}
}

terminalNoDeadlineExceeded := watchTerminalNoDeadlineExceeded(ctx, exps, host)
willShutdownCtx, fireWillShutdown := context.WithCancel(ctx)
termMux := terminal.NewMux()
termMuxSrv := terminal.NewMuxTerminalService(termMux, terminalNoDeadlineExceeded)
termMuxSrv := terminal.NewMuxTerminalService(termMux)
termMuxSrv.DefaultWorkdir = cfg.RepoRoot
if cfg.WorkspaceRoot != "" {
termMuxSrv.DefaultWorkdirProvider = func() string {
Expand Down Expand Up @@ -584,36 +582,6 @@ func getIDENotReadyShutdownDuration(ctx context.Context, exps experiments.Client
}
}

func watchTerminalNoDeadlineExceeded(ctx context.Context, exps experiments.Client, gitpodHost string) *atomic.Bool {
newBool := func(v bool) *atomic.Bool {
r := atomic.Bool{}
r.Store(v)
return &r
}
if exps == nil {
return newBool(false)
}

value := exps.GetBoolValue(ctx, "supervisor_terminal_no_deadline_exceeded", false, experiments.Attributes{GitpodHost: gitpodHost})
result := newBool(value)

go (func() {
t := time.NewTicker(30 * time.Second)

for {
select {
case <-ctx.Done():
return
case <-t.C:
value := exps.GetBoolValue(ctx, "supervisor_terminal_no_deadline_exceeded", false, experiments.Attributes{GitpodHost: gitpodHost})
result.Store(value)
}
}
})()

return result
}

func isShallowRepository(rootDir string) bool {
cmd := runAsGitpodUser(exec.Command("git", "rev-parse", "--is-shallow-repository"))
cmd.Dir = rootDir
Expand Down
9 changes: 1 addition & 8 deletions components/supervisor/pkg/supervisor/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"strconv"
"sync"
"sync/atomic"
"testing"

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

func newBool(b bool) *atomic.Bool {
result := atomic.Bool{}
result.Store(b)
return &result
}

var (
skipCommand = "echo \"skip\""
failCommand = "exit 1"
Expand Down Expand Up @@ -223,7 +216,7 @@ func TestTaskManager(t *testing.T) {
}

var (
terminalService = terminal.NewMuxTerminalService(terminal.NewMux(), newBool(true))
terminalService = terminal.NewMuxTerminalService(terminal.NewMux())
contentState = NewInMemoryContentState("")
reporter = testHeadlessTaskProgressReporter{}
taskManager = newTasksManager(&Config{
Expand Down
12 changes: 2 additions & 10 deletions components/supervisor/pkg/terminal/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"os"
"os/exec"
"path/filepath"
"sync/atomic"
"syscall"
"time"

Expand All @@ -27,7 +26,7 @@ import (
)

// NewMuxTerminalService creates a new terminal service.
func NewMuxTerminalService(m *Mux, terminalNoDeadlineExceeded *atomic.Bool) *MuxTerminalService {
func NewMuxTerminalService(m *Mux) *MuxTerminalService {
shell := os.Getenv("SHELL")
if shell == "" {
shell = "/bin/bash"
Expand All @@ -37,8 +36,6 @@ func NewMuxTerminalService(m *Mux, terminalNoDeadlineExceeded *atomic.Bool) *Mux
DefaultWorkdir: "/workspace",
DefaultShell: shell,
Env: os.Environ(),

terminalNoDeadlineExceeded: terminalNoDeadlineExceeded,
}
}

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

terminalNoDeadlineExceeded *atomic.Bool

api.UnimplementedTerminalServiceServer
}

Expand Down Expand Up @@ -291,10 +286,7 @@ func (srv *MuxTerminalService) Listen(req *api.ListenTerminalRequest, resp api.T
err = resp.Send(message)
case err = <-errchan:
case <-resp.Context().Done():
if srv.terminalNoDeadlineExceeded.Load() {
return nil
}
return status.Error(codes.DeadlineExceeded, resp.Context().Err().Error())
return nil
}
if err == io.EOF {
// EOF isn't really an error here
Expand Down
15 changes: 4 additions & 11 deletions components/supervisor/pkg/terminal/terminal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"os"
"os/exec"
"strings"
"sync/atomic"
"testing"
"time"

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

func newBool(b bool) *atomic.Bool {
result := atomic.Bool{}
result.Store(b)
return &result
}

func TestTitle(t *testing.T) {
t.Skip("skipping flakey tests")

Expand Down Expand Up @@ -66,7 +59,7 @@ func TestTitle(t *testing.T) {
}
defer os.RemoveAll(tmpWorkdir)

terminalService := NewMuxTerminalService(mux, newBool(true))
terminalService := NewMuxTerminalService(mux)
terminalService.DefaultWorkdir = tmpWorkdir

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

terminalService := NewMuxTerminalService(mux, newBool(true))
terminalService := NewMuxTerminalService(mux)
var err error
if test.Opts == nil {
_, err = terminalService.Open(ctx, test.Req)
Expand Down Expand Up @@ -255,7 +248,7 @@ func TestTerminals(t *testing.T) {
}
for _, test := range tests {
t.Run(test.Desc, func(t *testing.T) {
terminalService := NewMuxTerminalService(NewMux(), newBool(true))
terminalService := NewMuxTerminalService(NewMux())
resp, err := terminalService.Open(context.Background(), &api.OpenTerminalRequest{})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -336,7 +329,7 @@ func TestWorkDirProvider(t *testing.T) {
mux := NewMux()
defer mux.Close(ctx)

terminalService := NewMuxTerminalService(mux, newBool(true))
terminalService := NewMuxTerminalService(mux)

type AssertWorkDirTest struct {
expectedWorkDir string
Expand Down
Loading