Skip to content

Commit 899ac0e

Browse files
committed
Fix issue with the "Executing application" spinner never ending in KubeExec implementation
Spinner handling will be done in the KubeExecProcessHandler#Execute method itself, which executes the overridden command in a goroutine. Otherwise, we might end up with a never-ending spinner, because the overridden command might be a long-running process.
1 parent 0eb5180 commit 899ac0e

File tree

1 file changed

+7
-9
lines changed
  • pkg/devfile/adapters/kubernetes/component/remotecmd

1 file changed

+7
-9
lines changed

pkg/devfile/adapters/kubernetes/component/remotecmd/kubeexec.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
const (
2121
_startCmdProcessPidFile = "/opt/odo/.odo_devfile_cmd.pid"
22-
_sigtermExitCode = 143
22+
_sigtermExitCode = 143
2323
)
2424

2525
// kubeExecProcessHandler implements RemoteProcessHandler by executing Devfile commands right away in the container
@@ -132,10 +132,11 @@ func (k *kubeExecProcessHandler) GetStartStopCommands(
132132
// by killing the underlying remote process via the Stop command returned by GetStartStopCommands.
133133
// Note that resultHandler is invoked once the command is done.
134134
func (k *kubeExecProcessHandlerStartCommand) Execute(show bool, resultHandler command.ExecuteResultHandler) error {
135-
spinner := log.SpinnerNoSpin(k.msg)
136-
go func(spinner *log.Status) {
137-
defer spinner.End(false)
138-
err := k.cmd.Execute(show, func(stdout []string, stderr []string, err error) {
135+
//We use a static spinner here, because otherwise, ending the spinner will cause the "• Executing the application ..."
136+
//message to be displayed twice once the spinner ends
137+
_ = log.SpinnerNoSpin(k.msg)
138+
go func() {
139+
_ = k.cmd.Execute(show, func(stdout []string, stderr []string, err error) {
139140
if resultHandler != nil {
140141
resultHandler(stdout, stderr, err)
141142
}
@@ -155,10 +156,7 @@ func (k *kubeExecProcessHandlerStartCommand) Execute(show bool, resultHandler co
155156
}
156157
}
157158
})
158-
if err == nil {
159-
spinner.End(true)
160-
}
161-
}(spinner)
159+
}()
162160
return nil
163161
}
164162

0 commit comments

Comments
 (0)