Skip to content

Commit 4025bc1

Browse files
committed
Mark the AddSshAgentPostStartEvent as experimental feature
Signed-off-by: ivinokur <[email protected]>
1 parent ff72383 commit 4025bc1

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

controllers/workspace/devworkspace_controller.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ import (
6565
"sigs.k8s.io/controller-runtime/pkg/reconcile"
6666
"sigs.k8s.io/controller-runtime/pkg/source"
6767

68+
"github.com/devfile/devworkspace-operator/pkg/config"
69+
6870
dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
6971
wsDefaults "github.com/devfile/devworkspace-operator/pkg/library/defaults"
7072
)
@@ -131,20 +133,20 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
131133
}
132134

133135
reconcileStatus := currentStatus{}
134-
config, err := wkspConfig.ResolveConfigForWorkspace(rawWorkspace, clusterAPI.Client)
136+
workspaceConfig, err := wkspConfig.ResolveConfigForWorkspace(rawWorkspace, clusterAPI.Client)
135137
if err != nil {
136138
reconcileStatus.addWarning(fmt.Sprint("Error applying external DevWorkspace-Operator configuration: ", err.Error()))
137-
config = wkspConfig.GetGlobalConfig()
139+
workspaceConfig = wkspConfig.GetGlobalConfig()
138140
}
139-
configString := wkspConfig.GetCurrentConfigString(config)
141+
configString := wkspConfig.GetCurrentConfigString(workspaceConfig)
140142
workspace := &common.DevWorkspaceWithConfig{}
141143
workspace.DevWorkspace = rawWorkspace
142-
workspace.Config = config
144+
workspace.Config = workspaceConfig
143145

144146
reqLogger = reqLogger.WithValues(constants.DevWorkspaceIDLoggerKey, workspace.Status.DevWorkspaceId)
145147
reqLogger.Info("Reconciling Workspace", "resolvedConfig", configString)
146148

147-
// Inject ca certificates to the http client, if the certificates configmap is created and defined in the config.
149+
// Inject ca certificates to the http client, if the certificates configmap is created and defined in the workspaceConfig.
148150
InjectCertificates(r.Client, r.Log)
149151

150152
// Check if the DevWorkspaceRouting instance is marked to be deleted, which is
@@ -281,9 +283,12 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
281283
}
282284
workspace.Spec.Template = *flattenedWorkspace
283285

284-
err = ssh.AddSshAgentPostStartEvent(&workspace.Spec.Template)
285-
if err != nil {
286-
return r.failWorkspace(workspace, "Failed to add ssh-agent post start event", metrics.ReasonWorkspaceEngineFailure, reqLogger, &reconcileStatus), nil
286+
// Include to experimental features list because it is not clear how to handle post start events in containers without sh.
287+
if *config.GetGlobalConfig().EnableExperimentalFeatures {
288+
err = ssh.AddSshAgentPostStartEvent(&workspace.Spec.Template)
289+
if err != nil {
290+
return r.failWorkspace(workspace, "Failed to add ssh-agent post start event", metrics.ReasonWorkspaceEngineFailure, reqLogger, &reconcileStatus), nil
291+
}
287292
}
288293

289294
reconcileStatus.setConditionTrue(conditions.DevWorkspaceResolved, "Resolved plugins and parents from DevWorkspace")
@@ -345,9 +350,9 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
345350
Resources: workspace.Config.Workspace.ProjectCloneConfig.Resources,
346351
}
347352
if workspace.Config.Workspace.ProjectCloneConfig.ImagePullPolicy != "" {
348-
projectCloneOptions.PullPolicy = config.Workspace.ProjectCloneConfig.ImagePullPolicy
353+
projectCloneOptions.PullPolicy = workspaceConfig.Workspace.ProjectCloneConfig.ImagePullPolicy
349354
} else {
350-
projectCloneOptions.PullPolicy = corev1.PullPolicy(config.Workspace.ImagePullPolicy)
355+
projectCloneOptions.PullPolicy = corev1.PullPolicy(workspaceConfig.Workspace.ImagePullPolicy)
351356
}
352357
if projectClone, err := projects.GetProjectCloneInitContainer(&workspace.Spec.Template, projectCloneOptions, workspace.Config.Routing.ProxyConfig); err != nil {
353358
return r.failWorkspace(workspace, fmt.Sprintf("Failed to set up project-clone init container: %s", err), metrics.ReasonInfrastructureFailure, reqLogger, &reconcileStatus), nil

docs/additional-configuration.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ you must add the following in your `~/.bashrc`:
225225
----
226226
[ -f $HOME/ssh-environment ] && source $HOME/ssh-environment
227227
----
228+
*Note:* This is an experimental feature and is controlled by the `DevWorkspaceOperatorConfig.EnableExperimentalFeatures` option.
228229
229230
3. Annotate the secret to configure automatic mounting to DevWorkspaces
230231
+

0 commit comments

Comments
 (0)