Skip to content

Commit

Permalink
Mark the AddSshAgentPostStartEvent as experimental feature
Browse files Browse the repository at this point in the history
Signed-off-by: ivinokur <[email protected]>
  • Loading branch information
vinokurig committed Nov 6, 2024
1 parent ff72383 commit 129b8c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
23 changes: 14 additions & 9 deletions controllers/workspace/devworkspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/devfile/devworkspace-operator/pkg/config"

dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
wsDefaults "github.com/devfile/devworkspace-operator/pkg/library/defaults"
)
Expand Down Expand Up @@ -131,15 +133,15 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
}

reconcileStatus := currentStatus{}
config, err := wkspConfig.ResolveConfigForWorkspace(rawWorkspace, clusterAPI.Client)
workspaceConfig, err := wkspConfig.ResolveConfigForWorkspace(rawWorkspace, clusterAPI.Client)
if err != nil {
reconcileStatus.addWarning(fmt.Sprint("Error applying external DevWorkspace-Operator configuration: ", err.Error()))
config = wkspConfig.GetGlobalConfig()
workspaceConfig = wkspConfig.GetGlobalConfig()
}
configString := wkspConfig.GetCurrentConfigString(config)
configString := wkspConfig.GetCurrentConfigString(workspaceConfig)
workspace := &common.DevWorkspaceWithConfig{}
workspace.DevWorkspace = rawWorkspace
workspace.Config = config
workspace.Config = workspaceConfig

reqLogger = reqLogger.WithValues(constants.DevWorkspaceIDLoggerKey, workspace.Status.DevWorkspaceId)
reqLogger.Info("Reconciling Workspace", "resolvedConfig", configString)
Expand Down Expand Up @@ -281,9 +283,12 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
}
workspace.Spec.Template = *flattenedWorkspace

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

reconcileStatus.setConditionTrue(conditions.DevWorkspaceResolved, "Resolved plugins and parents from DevWorkspace")
Expand Down Expand Up @@ -345,9 +350,9 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
Resources: workspace.Config.Workspace.ProjectCloneConfig.Resources,
}
if workspace.Config.Workspace.ProjectCloneConfig.ImagePullPolicy != "" {
projectCloneOptions.PullPolicy = config.Workspace.ProjectCloneConfig.ImagePullPolicy
projectCloneOptions.PullPolicy = workspaceConfig.Workspace.ProjectCloneConfig.ImagePullPolicy
} else {
projectCloneOptions.PullPolicy = corev1.PullPolicy(config.Workspace.ImagePullPolicy)
projectCloneOptions.PullPolicy = corev1.PullPolicy(workspaceConfig.Workspace.ImagePullPolicy)
}
if projectClone, err := projects.GetProjectCloneInitContainer(&workspace.Spec.Template, projectCloneOptions, workspace.Config.Routing.ProxyConfig); err != nil {
return r.failWorkspace(workspace, fmt.Sprintf("Failed to set up project-clone init container: %s", err), metrics.ReasonInfrastructureFailure, reqLogger, &reconcileStatus), nil
Expand Down
1 change: 1 addition & 0 deletions docs/additional-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ you must add the following in your `~/.bashrc`:
----
[ -f $HOME/ssh-environment ] && source $HOME/ssh-environment
----
*Note:* This is an experimental feature and is controlled by the `DevWorkspaceOperatorConfig.EnableExperimentalFeatures` option.
3. Annotate the secret to configure automatic mounting to DevWorkspaces
+
Expand Down

0 comments on commit 129b8c7

Please sign in to comment.