Stop other commands in case of restart false
* Stop other commands in case of restart false
stop debug command, if we are running run command and vice versa
* Update if blocks
* Updated with mrinal's suggestion
Get mode from env.yaml
* Address review comments
* Simplify implementation
package common
import (
+ "io"
+ "strings"
+
+ "github.com/openshift/odo/pkg/envinfo"
+
"github.com/openshift/odo/pkg/devfile/parser/data/common"
"github.com/openshift/odo/pkg/log"
"github.com/openshift/odo/pkg/machineoutput"
"github.com/pkg/errors"
- "io"
"k8s.io/klog"
- "strings"
)
// ComponentInfoFactory defines a type for a function which creates a ComponentInfo based on the information provided by the specified DevfileCommand.
@@ -119,11 +122,16 @@ func (a GenericAdapter) ExecDevfile(commandsMap PushCommandsMap, componentExists
return err
}
+ previousMode := params.EnvSpecificInfo.GetRunMode()
+ currentMode := envinfo.Run
+
group := common.RunCommandGroupType
defaultCmd := string(DefaultDevfileRunCommand)
+
if params.Debug {
group = common.DebugCommandGroupType
defaultCmd = string(DefaultDevfileDebugCommand)
+ currentMode = envinfo.Debug
}
if command, ok := commandsMap[group]; ok {
@@ -137,9 +145,12 @@ func (a GenericAdapter) ExecDevfile(commandsMap PushCommandsMap, componentExists
}
}
+ restart := IsRestartRequired(command)
+
// if we need to restart, issue supervisor command to stop all running commands first
- if componentExists && IsRestartRequired(command) {
- klog.V(4).Infof("restart:true, restarting %s", defaultCmd)
+ if componentExists {
+ if restart || (previousMode != currentMode) {
+ klog.V(4).Infof("supervisord stop command %s to restart or start other command", previousMode)
if cmd, err := newSupervisorStopCommand(command, a); cmd != nil {
if err != nil {
return err
@@ -149,6 +160,7 @@ func (a GenericAdapter) ExecDevfile(commandsMap PushCommandsMap, componentExists
} else {
klog.V(4).Infof("restart:false, not restarting %s", defaultCmd)
}
+ }
// with restart false, executing only supervisord start command, if the command is already running, supvervisord will not restart it.
// if the command is failed or not running supervisord would start it.
