From f83e513a1f2b0e136d4f61e92d4189125f900fd4 Mon Sep 17 00:00:00 2001 From: Laurent Luce Date: Tue, 29 Aug 2023 22:57:34 -0400 Subject: [PATCH] fix: Point to the engine restart command as part of the context switch failure remediation to not conflict with lower level commands (#1191) ## Description: The engine remediation command in the context switch logic sometimes conflicts with lower level engine remediation commands. One example is when the running engine version does not match the CLI version, the user is presented with two remediation commands: `engine start` and `engine restart`. Only the second one remediates the issue. This change updates the engine remediation command in the context switch logic to be `engine restart` which also works if the engine is not running. Note that we don't want to restart the engine automatically when there is a version mismatch because different users could be using different CLI versions and we don't want to end up in a tug of war match. ## Is this change user facing? YES --- cli/cli/commands/kurtosis_context/context_switch/switch.go | 6 +++--- .../helpers/engine_manager/engine_existence_guarantor.go | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cli/cli/commands/kurtosis_context/context_switch/switch.go b/cli/cli/commands/kurtosis_context/context_switch/switch.go index 3be173d623..b86f4b4a2c 100644 --- a/cli/cli/commands/kurtosis_context/context_switch/switch.go +++ b/cli/cli/commands/kurtosis_context/context_switch/switch.go @@ -71,7 +71,7 @@ func SwitchContext( "needs to be stopped before the context can be switched. The engine status can be obtained running"+ "kurtosis %s %s and it can be stopped manually by running kurtosis %s %s.", command_str_consts.EngineCmdStr, command_str_consts.EngineStatusCmdStr, - command_str_consts.EngineCmdStr, command_str_consts.EngineStartCmdStr) + command_str_consts.EngineCmdStr, command_str_consts.EngineStopCmdStr) } } @@ -144,8 +144,8 @@ func SwitchContext( _, engineClientCloseFunc, startEngineErr := engineManager.StartEngineIdempotentlyWithDefaultVersion(ctx, logrus.InfoLevel, defaults.DefaultEngineEnclavePoolSize) if startEngineErr != nil { logrus.Warnf("The context was successfully switched to '%s' but Kurtosis failed to start an engine in "+ - "this new context. An engine should be started manually with 'kurtosis %s %s'. The error was:\n%v", - contextIdentifier, command_str_consts.EngineCmdStr, command_str_consts.EngineStartCmdStr, startEngineErr) + "this new context. A new engine should be started manually with '%s %s %s'. The error was:\n%v", + contextIdentifier, command_str_consts.KurtosisCmdStr, command_str_consts.EngineCmdStr, command_str_consts.EngineRestartCmdStr, startEngineErr) } else { defer func() { if err = engineClientCloseFunc(); err != nil { diff --git a/cli/cli/helpers/engine_manager/engine_existence_guarantor.go b/cli/cli/helpers/engine_manager/engine_existence_guarantor.go index c6f46310c7..96dc63c3cf 100644 --- a/cli/cli/helpers/engine_manager/engine_existence_guarantor.go +++ b/cli/cli/helpers/engine_manager/engine_existence_guarantor.go @@ -187,13 +187,10 @@ func (guarantor *engineExistenceGuarantor) VisitStopped() error { // unusual and very bad, so we'd rather fail loudly func (guarantor *engineExistenceGuarantor) VisitContainerRunningButServerNotResponding() error { remediationCmd := fmt.Sprintf( - "%v %v %v && %v %v %v", + "%v %v %v", command_str_consts.KurtosisCmdStr, command_str_consts.EngineCmdStr, - command_str_consts.EngineStopCmdStr, - command_str_consts.KurtosisCmdStr, - command_str_consts.EngineCmdStr, - command_str_consts.EngineStartCmdStr, + command_str_consts.EngineRestartCmdStr, ) return stacktrace.NewError( "We couldn't guarantee that a Kurtosis engine is running because we found a running engine container whose server isn't "+