Skip to content

Commit d34d01c

Browse files
authored
feat: add failsafe reason for video max restart attempts reached (#991)
1 parent 641b031 commit d34d01c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

failsafe.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"os"
66
"strings"
77
"sync"
8+
9+
"github.com/jetkvm/kvm/internal/supervisor"
810
)
911

1012
const (
@@ -78,6 +80,10 @@ func checkFailsafeReason() {
7880

7981
// TODO: read the goroutine stack trace and check which goroutine is panicking
8082
failsafeModeActive = true
83+
if strings.Contains(failsafeCrashLog, supervisor.FailsafeReasonVideoMaxRestartAttemptsReached) {
84+
failsafeModeReason = "video"
85+
return
86+
}
8187
if strings.Contains(failsafeCrashLog, "runtime.cgocall") {
8288
failsafeModeReason = "video"
8389
return

internal/native/proxy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"time"
1616

1717
"github.com/Masterminds/semver/v3"
18+
"github.com/jetkvm/kvm/internal/supervisor"
1819
"github.com/jetkvm/kvm/internal/utils"
1920
"github.com/rs/zerolog"
2021
)
@@ -422,7 +423,7 @@ func (p *NativeProxy) restartProcess() error {
422423
logger := p.logger.With().Uint("attempt", p.restarts).Uint("maxAttempts", p.options.MaxRestartAttempts).Logger()
423424

424425
if p.restarts >= p.options.MaxRestartAttempts {
425-
logger.Fatal().Msg("max restart attempts reached, exiting")
426+
logger.Fatal().Msgf("max restart attempts reached, exiting: %s", supervisor.FailsafeReasonVideoMaxRestartAttemptsReached)
426427
return fmt.Errorf("max restart attempts reached")
427428
}
428429

internal/supervisor/consts.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ const (
66
ErrorDumpDir = "/userdata/jetkvm/crashdump" // The error dump directory is the directory where the error dumps are stored
77
ErrorDumpLastFile = "last-crash.log" // The error dump last file is the last error dump file
88
ErrorDumpTemplate = "jetkvm-%s.log" // The error dump template is the template for the error dump file
9+
10+
FailsafeReasonVideoMaxRestartAttemptsReached = "failsafe::video.max_restart_attempts_reached"
911
)

0 commit comments

Comments
 (0)