Skip to content

Commit 3f066ce

Browse files
authored
[supervisor] revert recent changes to reduce frequency of supervisor run error with unexpected exit code (#20325)
* Revert "[supervisor] switch lib back to use upstream `ramr/go-reaper` (#20322)" This reverts commit 9442b52. * Revert "[supervisor] set pod failure reason when supervisor is reaped (#20318)" This reverts commit 9e8da3b.
1 parent 6bc053e commit 3f066ce

File tree

3 files changed

+11
-48
lines changed

3 files changed

+11
-48
lines changed

components/supervisor/cmd/init.go

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -77,59 +77,25 @@ var initCmd = &cobra.Command{
7777
}
7878

7979
supervisorDone := make(chan struct{})
80-
handledByReaper := make(chan int)
81-
handleSupervisorExit := func(exitCode int) {
82-
if exitCode == 0 {
83-
return
84-
}
85-
logs := extractFailureFromRun()
86-
if shared.IsExpectedShutdown(exitCode) {
87-
log.Fatal(logs)
88-
} else {
89-
log.WithError(fmt.Errorf(logs)).Fatal("supervisor run error with unexpected exit code")
90-
}
91-
}
9280
go func() {
9381
defer close(supervisorDone)
9482

9583
err := runCommand.Wait()
96-
if err == nil {
97-
return
98-
}
99-
// exited by reaper
100-
if strings.Contains(err.Error(), "no child processes") {
101-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
102-
defer cancel()
103-
select {
104-
case <-ctx.Done(): // timeout
105-
case exitCode := <-handledByReaper:
106-
handleSupervisorExit(exitCode)
107-
}
108-
} else if !(strings.Contains(err.Error(), "signal: ")) {
84+
if err != nil && !(strings.Contains(err.Error(), "signal: ") || strings.Contains(err.Error(), "no child processes")) {
10985
if eerr, ok := err.(*exec.ExitError); ok && eerr.ExitCode() != 0 {
110-
handleSupervisorExit(eerr.ExitCode())
86+
logs := extractFailureFromRun()
87+
if shared.IsExpectedShutdown(eerr.ExitCode()) {
88+
log.Fatal(logs)
89+
} else {
90+
log.WithError(fmt.Errorf(logs)).Fatal("supervisor run error with unexpected exit code")
91+
}
11192
}
11293
log.WithError(err).Error("supervisor run error")
11394
return
11495
}
11596
}()
11697
// start the reaper to clean up zombie processes
117-
reaperChan := make(chan reaper.Status, 10)
118-
reaper.Start(reaper.Config{
119-
Pid: -1,
120-
Options: 0,
121-
DisablePid1Check: false,
122-
StatusChannel: reaperChan,
123-
})
124-
go func() {
125-
for status := range reaperChan {
126-
if status.Pid != runCommand.Process.Pid {
127-
continue
128-
}
129-
exitCode := status.WaitStatus.ExitStatus()
130-
handledByReaper <- exitCode
131-
}
132-
}()
98+
reaper.Reap()
13399

134100
select {
135101
case <-supervisorDone:

components/supervisor/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
github.com/gitpod-io/gitpod/ide-metrics-api v0.0.0-00010101000000-000000000000
1717
github.com/gitpod-io/gitpod/supervisor/api v0.0.0-00010101000000-000000000000
1818
github.com/gitpod-io/gitpod/ws-daemon/api v0.0.0-00010101000000-000000000000
19-
github.com/gitpod-io/go-reaper v0.0.0-20241024192051-78d04cc2e25f
2019
github.com/golang/mock v1.6.0
2120
github.com/google/go-cmp v0.6.0
2221
github.com/google/uuid v1.6.0
@@ -30,7 +29,7 @@ require (
3029
github.com/prometheus/common v0.42.0
3130
github.com/prometheus/procfs v0.10.1
3231
github.com/prometheus/pushgateway v1.5.1
33-
github.com/ramr/go-reaper v0.2.2
32+
github.com/ramr/go-reaper v0.2.1
3433
github.com/sirupsen/logrus v1.9.3
3534
github.com/soheilhy/cmux v0.1.5
3635
github.com/spf13/cobra v1.4.0

components/supervisor/go.sum

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)