Skip to content

Commit 1bf5869

Browse files
authored
fix: ensure unique init ssh agent command for all components (#1329)
Signed-off-by: ivinokur <[email protected]>
1 parent 75c2a60 commit 1bf5869

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pkg/constants/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const (
4545

4646
HomeInitEventId = "init-persistent-home"
4747

48-
SshAgentStartEventId = "init-ssh-agent"
48+
SshAgentStartEventId = "init-ssh-agent-command"
4949

5050
ServiceAccount = "devworkspace"
5151

pkg/library/ssh/event.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
package ssh
1515

1616
import (
17+
"fmt"
18+
1719
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
1820
"github.com/devfile/devworkspace-operator/pkg/constants"
1921
"github.com/devfile/devworkspace-operator/pkg/library/lifecycle"
@@ -38,20 +40,21 @@ func AddSshAgentPostStartEvent(spec *v1alpha2.DevWorkspaceTemplateSpec) error {
3840
}
3941

4042
_, mainComponents, err := lifecycle.GetInitContainers(spec.DevWorkspaceTemplateSpecContent)
41-
for _, component := range mainComponents {
43+
for id, component := range mainComponents {
4244
if component.Container == nil {
4345
continue
4446
}
47+
commandId := fmt.Sprintf("%s-%d", constants.SshAgentStartEventId, id)
4548
spec.Commands = append(spec.Commands, v1alpha2.Command{
46-
Id: constants.SshAgentStartEventId,
49+
Id: commandId,
4750
CommandUnion: v1alpha2.CommandUnion{
4851
Exec: &v1alpha2.ExecCommand{
4952
CommandLine: commandLine,
5053
Component: component.Name,
5154
},
5255
},
5356
})
57+
spec.Events.PostStart = append(spec.Events.PostStart, commandId)
5458
}
55-
spec.Events.PostStart = append(spec.Events.PostStart, constants.SshAgentStartEventId)
5659
return err
5760
}

0 commit comments

Comments
 (0)