feat: add failsafe reason for video max restart attempts reached (#991)

This commit is contained in:
Aveline 2025-11-20 17:32:54 +01:00 committed by GitHub
parent 641b03199e
commit d34d01c4b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import (
"os"
"strings"
"sync"
"github.com/jetkvm/kvm/internal/supervisor"
)
const (
@ -78,6 +80,10 @@ func checkFailsafeReason() {
// TODO: read the goroutine stack trace and check which goroutine is panicking
failsafeModeActive = true
if strings.Contains(failsafeCrashLog, supervisor.FailsafeReasonVideoMaxRestartAttemptsReached) {
failsafeModeReason = "video"
return
}
if strings.Contains(failsafeCrashLog, "runtime.cgocall") {
failsafeModeReason = "video"
return

View File

@ -15,6 +15,7 @@ import (
"time"
"github.com/Masterminds/semver/v3"
"github.com/jetkvm/kvm/internal/supervisor"
"github.com/jetkvm/kvm/internal/utils"
"github.com/rs/zerolog"
)
@ -422,7 +423,7 @@ func (p *NativeProxy) restartProcess() error {
logger := p.logger.With().Uint("attempt", p.restarts).Uint("maxAttempts", p.options.MaxRestartAttempts).Logger()
if p.restarts >= p.options.MaxRestartAttempts {
logger.Fatal().Msg("max restart attempts reached, exiting")
logger.Fatal().Msgf("max restart attempts reached, exiting: %s", supervisor.FailsafeReasonVideoMaxRestartAttemptsReached)
return fmt.Errorf("max restart attempts reached")
}

View File

@ -6,4 +6,6 @@ const (
ErrorDumpDir = "/userdata/jetkvm/crashdump" // The error dump directory is the directory where the error dumps are stored
ErrorDumpLastFile = "last-crash.log" // The error dump last file is the last error dump file
ErrorDumpTemplate = "jetkvm-%s.log" // The error dump template is the template for the error dump file
FailsafeReasonVideoMaxRestartAttemptsReached = "failsafe::video.max_restart_attempts_reached"
)