vm run --rm: suppress the still-running reminder
The deferred --rm delete fires AFTER runSSHSession returns, but runSSHSession prints "vm X is still running (stop with ...)" before returning. Net effect: the user sees the reminder, then the VM gets deleted behind it — misleading. Thread a skipReminder bool into runSSHSession. `vm run` passes the same value as removeOnExit; other callers (`vm ssh`) pass false. Reinforced by a new assertion in the --rm happy-path test that the reminder string never appears in stderr. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b33f24865c
commit
cdd857b288
2 changed files with 12 additions and 7 deletions
|
|
@ -1135,7 +1135,7 @@ func newVMSSHCommand() *cobra.Command {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return runSSHSession(cmd.Context(), layout.SocketPath, result.Name, cmd.InOrStdin(), cmd.OutOrStdout(), cmd.ErrOrStderr(), sshArgs)
|
||||
return runSSHSession(cmd.Context(), layout.SocketPath, result.Name, cmd.InOrStdin(), cmd.OutOrStdout(), cmd.ErrOrStderr(), sshArgs, false)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2475,9 +2475,9 @@ func validatePositiveSetting(label string, value int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func runSSHSession(ctx context.Context, socketPath, vmRef string, stdin io.Reader, stdout, stderr io.Writer, sshArgs []string) error {
|
||||
func runSSHSession(ctx context.Context, socketPath, vmRef string, stdin io.Reader, stdout, stderr io.Writer, sshArgs []string, skipReminder bool) error {
|
||||
sshErr := sshExecFunc(ctx, stdin, stdout, stderr, sshArgs)
|
||||
if !shouldCheckSSHReminder(sshErr) || ctx.Err() != nil {
|
||||
if skipReminder || !shouldCheckSSHReminder(sshErr) || ctx.Err() != nil {
|
||||
return sshErr
|
||||
}
|
||||
pingCtx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
|
|
@ -2890,7 +2890,7 @@ func runVMRun(ctx context.Context, socketPath string, cfg model.DaemonConfig, st
|
|||
return nil
|
||||
}
|
||||
progress.render("attaching to guest")
|
||||
return runSSHSession(ctx, socketPath, vmRef, stdin, stdout, stderr, sshArgs)
|
||||
return runSSHSession(ctx, socketPath, vmRef, stdin, stdout, stderr, sshArgs, removeOnExit)
|
||||
}
|
||||
|
||||
func importVMRunRepoToGuest(ctx context.Context, client vmRunGuestClient, spec vmRunRepoSpec, progress *vmRunProgressRenderer) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue