Skip to content

Commit

Permalink
fix: Point to the engine restart command as part of the context switc…
Browse files Browse the repository at this point in the history
…h 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
  • Loading branch information
laurentluce committed Aug 30, 2023
1 parent 1e123cc commit f83e513
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cli/cli/commands/kurtosis_context/context_switch/switch.go
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 2 additions & 5 deletions cli/cli/helpers/engine_manager/engine_existence_guarantor.go
Expand Up @@ -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 "+
Expand Down

0 comments on commit f83e513

Please sign in to comment.