From 731e7820a60998702d52b98e4563a90979ded0b8 Mon Sep 17 00:00:00 2001 From: ivinokur Date: Mon, 21 Oct 2024 12:50:17 +0300 Subject: [PATCH] Fix Start ssh-agent post start event Signed-off-by: ivinokur --- pkg/constants/constants.go | 2 +- pkg/library/ssh/event.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index d50079c2c..e5e021200 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -45,7 +45,7 @@ const ( HomeInitEventId = "init-persistent-home" - SshAgentStartEventId = "init-ssh-agent" + SshAgentStartEventId = "init-ssh-agent-command" ServiceAccount = "devworkspace" diff --git a/pkg/library/ssh/event.go b/pkg/library/ssh/event.go index 309506e97..a02435121 100644 --- a/pkg/library/ssh/event.go +++ b/pkg/library/ssh/event.go @@ -14,6 +14,7 @@ package ssh import ( + "fmt" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/devworkspace-operator/pkg/constants" "github.com/devfile/devworkspace-operator/pkg/library/lifecycle" @@ -38,12 +39,13 @@ func AddSshAgentPostStartEvent(spec *v1alpha2.DevWorkspaceTemplateSpec) error { } _, mainComponents, err := lifecycle.GetInitContainers(spec.DevWorkspaceTemplateSpecContent) - for _, component := range mainComponents { + for id, component := range mainComponents { if component.Container == nil { continue } + commandId := fmt.Sprintf("%s-%d", constants.SshAgentStartEventId, id) spec.Commands = append(spec.Commands, v1alpha2.Command{ - Id: constants.SshAgentStartEventId, + Id: commandId, CommandUnion: v1alpha2.CommandUnion{ Exec: &v1alpha2.ExecCommand{ CommandLine: commandLine, @@ -51,7 +53,7 @@ func AddSshAgentPostStartEvent(spec *v1alpha2.DevWorkspaceTemplateSpec) error { }, }, }) + spec.Events.PostStart = append(spec.Events.PostStart, commandId) } - spec.Events.PostStart = append(spec.Events.PostStart, constants.SshAgentStartEventId) return err }