diff --git a/pkg/component/execute_terminating.go b/pkg/component/execute_terminating.go index 1527a768831..bd34d402411 100644 --- a/pkg/component/execute_terminating.go +++ b/pkg/component/execute_terminating.go @@ -2,6 +2,7 @@ package component import ( "context" + "errors" "fmt" "io" @@ -63,6 +64,10 @@ func ExecuteTerminatingCommand(ctx context.Context, execClient exec.Client, plat return fmt.Errorf("unable to log error %v: %w", err, errLog) } } + + if errors.Is(err, context.Canceled) { + fmt.Println("TODO: kill command") + } return err } diff --git a/pkg/odo/cli/run/run.go b/pkg/odo/cli/run/run.go index c150e8b3dd7..3f92a4dda60 100644 --- a/pkg/odo/cli/run/run.go +++ b/pkg/odo/cli/run/run.go @@ -50,6 +50,14 @@ func (o *RunOptions) SetClientset(clientset *clientset.Clientset) { o.clientset = clientset } +func (o *RunOptions) HandleSignal(ctx context.Context, cancelFunc context.CancelFunc) error { + fmt.Println("canceling execution") + cancelFunc() + // At this point, `ctx.Done()` will be raised, and the cleanup will be done + // wait for the cleanup to finish and let the main thread finish instead of signal handler go routine from runnable + select {} +} + func (o *RunOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) error { o.commandName = args[0] // Value at 0 is expected to exist, thanks to ExactArgs(1) return nil