Skip to content

Commit 910ffb0

Browse files
committed
Switch to running without Supervisord
As discussed in [1], this will alleviate the maintenance burden, while waiting for [2] to get merged some day on the Devfile side. [1] redhat-developer#5768 (comment) [2] devfile/registry#102
1 parent 8abe985 commit 910ffb0

File tree

21 files changed

+54
-1172
lines changed

21 files changed

+54
-1172
lines changed

pkg/binding/mock.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/dev/dev.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func (o *DevClient) Start(
3434
ignorePaths []string,
3535
path string,
3636
debug bool,
37-
withSupervisord bool,
3837
) error {
3938
klog.V(4).Infoln("Creating new adapter")
4039
adapter, err := adapters.NewComponentAdapter(devfileObj.GetMetadataName(), path, "app", devfileObj, platformContext)
@@ -53,7 +52,6 @@ func (o *DevClient) Start(
5352
Path: path,
5453
IgnoredFiles: ignorePaths,
5554
Debug: debug,
56-
WithSupervisord: withSupervisord,
5755
}
5856

5957
klog.V(4).Infoln("Creating inner-loop resources for the component")
@@ -73,7 +71,6 @@ func (o *DevClient) Watch(
7371
h Handler,
7472
ctx context.Context,
7573
debug bool,
76-
withSupervisord bool,
7774
) error {
7875

7976
envSpecificInfo, err := envinfo.NewEnvSpecificInfo(path)
@@ -91,7 +88,6 @@ func (o *DevClient) Watch(
9188
InitialDevfileObj: devfileObj,
9289
Debug: debug,
9390
DebugPort: envSpecificInfo.GetDebugPort(),
94-
WithSupervisord: withSupervisord,
9591
}
9692

9793
return o.watchClient.WatchAndPush(out, watchParameters, ctx)

pkg/dev/interface.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@ import (
1515
type Client interface {
1616
// Start the resources in devfileObj on the platformContext. It then pushes the files in path to the container.
1717
// If debug is true, executes the debug command, or the run command by default.
18-
// If withSupervisord is false, Supervisord is not run.
1918
Start(
2019
devfileObj parser.DevfileObj,
2120
platformContext kubernetes.KubernetesContext,
2221
ignorePaths []string,
2322
path string,
2423
debug bool,
25-
withSupervisord bool,
2624
) error
2725

2826
// Watch watches for any changes to the files under path while ignoring the files/directories in ignorePaths.
2927
// It logs messages to out and uses the Handler h to perform push operation when anything changes in path.
3028
// It uses devfileObj to notify user to restart odo dev if they change endpoint information in the devfile.
3129
// If debug is true, the debug command will be started after a sync, or the run command by default.
32-
// If withSupervisord is false, Supervisord is not run.
3330
Watch(
3431
devfileObj parser.DevfileObj,
3532
path string,
@@ -38,7 +35,6 @@ type Client interface {
3835
h Handler,
3936
ctx context.Context,
4037
debug bool,
41-
withSupervisord bool,
4238
) error
4339
}
4440

pkg/dev/mock.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/devfile/adapters/common/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ import (
77
// ComponentAdapter defines the functions that platform-specific adapters must implement
88
type ComponentAdapter interface {
99
Push(parameters PushParameters) error
10-
CheckRemoteCommandStatus(withSupervisord bool, command devfilev1.Command) error
10+
CheckRemoteCommandStatus(command devfilev1.Command) error
1111
}

pkg/devfile/adapters/common/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type PushParameters struct {
3131
Debug bool // Runs the component in debug mode
3232
DebugPort int // Port used for remote debugging
3333
RunModeChanged bool // It determines if run mode is changed from run to debug or vice versa
34-
WithSupervisord bool // Whether to run with supervisord
3534
}
3635

3736
// SyncParameters is a struct containing the parameters to be used when syncing a devfile component

pkg/devfile/adapters/common/utils.go

Lines changed: 1 addition & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,29 @@
11
package common
22

33
import (
4-
"os"
54
"path/filepath"
65
"strings"
76

8-
"k8s.io/klog"
9-
107
devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
11-
parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common"
128
)
139

14-
// PredefinedDevfileCommands encapsulates constants for predefined devfile commands
15-
type PredefinedDevfileCommands string
16-
1710
const (
18-
19-
// DefaultDevfileRunCommand is a predefined devfile command for run
20-
DefaultDevfileRunCommand PredefinedDevfileCommands = "devrun"
21-
22-
// DefaultDevfileDebugCommand is a predefined devfile command for debug
23-
DefaultDevfileDebugCommand PredefinedDevfileCommands = "debugrun"
24-
25-
// SupervisordInitContainerName The init container name for supervisord
26-
SupervisordInitContainerName = "copy-supervisord"
27-
28-
// Default Image that will be used containing the supervisord binary and assembly scripts
29-
// use GetBootstrapperImage() function instead of this variable
30-
defaultBootstrapperImage = "registry.access.redhat.com/ocp-tools-4/odo-init-container-rhel8:1.1.11"
31-
3211
// SharedDataVolumeName Create a custom name and (hope) that users don't use the *exact* same name in their deployment (occlient.go)
3312
SharedDataVolumeName = "odo-shared-data"
3413

35-
// SharedDataMountPath The supervisord Mount Path for the container mounting the supervisord volume
14+
// SharedDataMountPath The Mount Path for the container mounting the odo volume
3615
SharedDataMountPath = "/opt/odo/"
3716

38-
// SupervisordBinaryPath The supervisord binary path inside the container volume mount
39-
SupervisordBinaryPath = "/opt/odo/bin/supervisord"
40-
41-
// SupervisordConfFile The supervisord configuration file inside the container volume mount
42-
SupervisordConfFile = "/opt/odo/conf/devfile-supervisor.conf"
43-
44-
// OdoInitImageContents The path to the odo init image contents
45-
OdoInitImageContents = "/opt/odo-init/."
46-
47-
// ENV variable to overwrite image used to bootstrap SupervisorD in S2I and Devfile builder Image
48-
bootstrapperImageEnvName = "ODO_BOOTSTRAPPER_IMAGE"
49-
5017
// EnvProjectsRoot is the env defined for project mount in a component container when component's mountSources=true
5118
EnvProjectsRoot = "PROJECTS_ROOT"
5219

53-
// EnvOdoCommandRunWorkingDir is the env defined in the runtime component container which holds the work dir for the run command
54-
EnvOdoCommandRunWorkingDir = "ODO_COMMAND_RUN_WORKING_DIR"
55-
56-
// EnvOdoCommandRun is the env defined in the runtime component container which holds the run command to be executed
57-
EnvOdoCommandRun = "ODO_COMMAND_RUN"
58-
59-
// EnvOdoCommandDebugWorkingDir is the env defined in the runtime component container which holds the work dir for the debug command
60-
EnvOdoCommandDebugWorkingDir = "ODO_COMMAND_DEBUG_WORKING_DIR"
61-
62-
// EnvOdoCommandDebug is the env defined in the runtime component container which holds the debug command to be executed
63-
EnvOdoCommandDebug = "ODO_COMMAND_DEBUG"
64-
6520
// EnvDebugPort is the env defined in the runtime component container which holds the debug port for remote debugging
6621
EnvDebugPort = "DEBUG_PORT"
6722

6823
// ShellExecutable is the shell executable
6924
ShellExecutable = "/bin/sh"
70-
71-
// SupervisordCtlSubCommand is the supervisord sub command ctl
72-
SupervisordCtlSubCommand = "ctl"
7325
)
7426

75-
// GetBootstrapperImage returns the odo-init bootstrapper image
76-
func GetBootstrapperImage() string {
77-
if env, ok := os.LookupEnv(bootstrapperImageEnvName); ok {
78-
return env
79-
}
80-
return defaultBootstrapperImage
81-
}
82-
83-
// getCommandsByGroup gets commands by the group kind
84-
func getCommandsByGroup(commands []devfilev1.Command, groupType devfilev1.CommandGroupKind) []devfilev1.Command {
85-
var filteredCommands []devfilev1.Command
86-
for _, command := range commands {
87-
commandGroup := parsercommon.GetGroup(command)
88-
if commandGroup != nil && commandGroup.Kind == groupType {
89-
filteredCommands = append(filteredCommands, command)
90-
}
91-
}
92-
93-
return filteredCommands
94-
}
95-
96-
// IsRestartRequired checks if restart required for run command
97-
func IsRestartRequired(hotReload bool, runModeChanged bool) bool {
98-
if runModeChanged || !hotReload {
99-
return true
100-
}
101-
102-
return false
103-
}
104-
105-
// IsEnvPresent checks if the env variable is present in an array of env variables
106-
func IsEnvPresent(envVars []devfilev1.EnvVar, envVarName string) bool {
107-
for _, envVar := range envVars {
108-
if envVar.Name == envVarName {
109-
return true
110-
}
111-
}
112-
113-
return false
114-
}
115-
116-
// IsPortPresent checks if the port is present in the endpoints array
117-
func IsPortPresent(endpoints []devfilev1.Endpoint, port int) bool {
118-
for _, endpoint := range endpoints {
119-
if endpoint.TargetPort == port {
120-
return true
121-
}
122-
}
123-
124-
return false
125-
}
126-
127-
// GetComponentEnvVar returns true if a list of env vars contains the specified env var
128-
// If the env exists, it returns the value of it
129-
func GetComponentEnvVar(env string, envs []devfilev1.EnvVar) string {
130-
for _, envVar := range envs {
131-
if envVar.Name == env {
132-
return envVar.Value
133-
}
134-
}
135-
return ""
136-
}
137-
138-
// GetCommandsFromEvent returns the list of commands from the event name.
139-
// If the event is a composite command, it returns the sub-commands from the tree
140-
func GetCommandsFromEvent(commandsMap map[string]devfilev1.Command, eventName string) []string {
141-
var commands []string
142-
143-
if command, ok := commandsMap[eventName]; ok {
144-
if command.Composite != nil {
145-
klog.V(4).Infof("%s is a composite command", command.Id)
146-
for _, compositeSubCmd := range command.Composite.Commands {
147-
klog.V(4).Infof("checking if sub-command %s is either an exec or a composite command ", compositeSubCmd)
148-
subCommands := GetCommandsFromEvent(commandsMap, strings.ToLower(compositeSubCmd))
149-
commands = append(commands, subCommands...)
150-
}
151-
} else {
152-
klog.V(4).Infof("%s is an exec command", command.Id)
153-
commands = append(commands, command.Id)
154-
}
155-
}
156-
157-
return commands
158-
}
159-
16027
// GetCommandsMap returns a map of the command Id to the command
16128
func GetCommandsMap(commands []devfilev1.Command) map[string]devfilev1.Command {
16229
commandMap := make(map[string]devfilev1.Command, len(commands))

pkg/devfile/adapters/common/utils_test.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package common
22

33
import (
4-
"os"
54
"reflect"
65
"testing"
76

@@ -93,41 +92,6 @@ func TestIsPortPresent(t *testing.T) {
9392

9493
}
9594

96-
func TestGetBootstrapperImage(t *testing.T) {
97-
98-
customImage := "customimage:customtag"
99-
100-
tests := []struct {
101-
name string
102-
customImage bool
103-
wantImage string
104-
}{
105-
{
106-
name: "Case 1: Default bootstrap image",
107-
customImage: false,
108-
wantImage: defaultBootstrapperImage,
109-
},
110-
{
111-
name: "Case 2: Custom bootstrap image",
112-
customImage: true,
113-
wantImage: customImage,
114-
},
115-
}
116-
for _, tt := range tests {
117-
t.Run(tt.name, func(t *testing.T) {
118-
if tt.customImage {
119-
os.Setenv(bootstrapperImageEnvName, customImage)
120-
}
121-
image := GetBootstrapperImage()
122-
123-
if image != tt.wantImage {
124-
t.Errorf("TestGetBootstrapperImage error: bootstrap image mismatch, expected: %v got: %v", tt.wantImage, image)
125-
}
126-
})
127-
}
128-
129-
}
130-
13195
func TestGetCommandsForGroup(t *testing.T) {
13296

13397
component := []devfilev1.Component{

pkg/devfile/adapters/kubernetes/adapter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func (k Adapter) Push(parameters common.PushParameters) error {
4242
return nil
4343
}
4444

45-
// CheckRemoteCommandStatus calls the component adapter's CheckSupervisordCommandStatus
46-
func (k Adapter) CheckRemoteCommandStatus(withSupervisord bool, command devfilev1.Command) error {
47-
err := k.componentAdapter.CheckRemoteCommandStatus(withSupervisord, command)
45+
// CheckRemoteCommandStatus calls the component adapter's CheckRemoteCommandStatus
46+
func (k Adapter) CheckRemoteCommandStatus(command devfilev1.Command) error {
47+
err := k.componentAdapter.CheckRemoteCommandStatus(command)
4848
if err != nil {
4949
return fmt.Errorf("failed to check the status: %w", err)
5050
}

0 commit comments

Comments
 (0)