From 0ef94db8e7fd708f96abfdd5b314346b83ff046b Mon Sep 17 00:00:00 2001 From: Siyuan Date: Thu, 20 Nov 2025 16:22:01 +0000 Subject: [PATCH] feat: add failsafe reason for video max restart attempts reached --- failsafe.go | 6 ++++++ internal/native/proxy.go | 3 ++- internal/supervisor/consts.go | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/failsafe.go b/failsafe.go index 14e7bbd5b..d7de1c816 100644 --- a/failsafe.go +++ b/failsafe.go @@ -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 diff --git a/internal/native/proxy.go b/internal/native/proxy.go index dda6a86e6..01f0bb115 100644 --- a/internal/native/proxy.go +++ b/internal/native/proxy.go @@ -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") } diff --git a/internal/supervisor/consts.go b/internal/supervisor/consts.go index 5f2884895..ab250553e 100644 --- a/internal/supervisor/consts.go +++ b/internal/supervisor/consts.go @@ -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" )