Skip to content

Commit 5e75e21

Browse files
authored
Merge pull request #1312 from YourTechBud/routing-fixes
fixed bugs found in routing module
2 parents 621cd11 + dc04422 commit 5e75e21

File tree

3 files changed

+20
-15
lines changed
  • gateway/modules/global/routing
  • runner/utils/driver/docker/proxy-manager
  • space-cli/cmd/modules/operations

3 files changed

+20
-15
lines changed

gateway/modules/global/routing/http.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (r *Routing) HandleRoutes(modules modulesInterface) http.HandlerFunc {
7676

7777
// Copy headers and status code
7878
for k, v := range response.Header {
79-
writer.Header().Set(k, v[0])
79+
writer.Header()[k] = v
8080
}
8181
writer.WriteHeader(response.StatusCode)
8282

runner/utils/driver/docker/proxy-manager/http.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (m *Manager) handleHTTPRequest(port int32) http.HandlerFunc {
5656

5757
// Copy headers and status code
5858
for k, v := range response.Header {
59-
writer.Header().Set(k, v[0])
59+
writer.Header()[k] = v
6060
}
6161
writer.WriteHeader(response.StatusCode)
6262

space-cli/cmd/modules/operations/destroy.go

+18-13
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,24 @@ func Destroy(clusterName string) error {
3333
// Remove all container
3434
for _, containerInfo := range containers {
3535
if containerInfo.Labels["service"] == string(model.ImageRunner) {
36-
// Make sure the container is running before deleting secrets
37-
if err := cli.ContainerStart(ctx, containerInfo.ID, types.ContainerStartOptions{}); err != nil {
38-
return err
39-
}
40-
// NOTE: files are created with root permission in runner. If host system want to delete these files it requires root permissions.
41-
// so to delete files without root permission we remove the files from container itself
42-
execProcess, err := cli.ContainerExecCreate(ctx, containerInfo.ID, types.ExecConfig{Cmd: []string{"rm", "-rf", "/secrets"}})
43-
if err != nil {
44-
return err
45-
}
46-
if err := cli.ContainerExecStart(ctx, execProcess.ID, types.ExecStartCheck{}); err != nil {
47-
return err
48-
}
36+
go func() {
37+
// Make sure the container is running before deleting secrets
38+
if err := cli.ContainerStart(ctx, containerInfo.ID, types.ContainerStartOptions{}); err != nil {
39+
_ = utils.LogError("Unable to start container to delete secrets", err)
40+
return
41+
}
42+
// NOTE: files are created with root permission in runner. If host system want to delete these files it requires root permissions.
43+
// so to delete files without root permission we remove the files from container itself
44+
execProcess, err := cli.ContainerExecCreate(ctx, containerInfo.ID, types.ExecConfig{Cmd: []string{"rm", "-rf", "/secrets"}})
45+
if err != nil {
46+
_ = utils.LogError("Unable to create delete secrets execution command", err)
47+
return
48+
}
49+
if err := cli.ContainerExecStart(ctx, execProcess.ID, types.ExecStartCheck{}); err != nil {
50+
_ = utils.LogError("Unable to execute delete secrets command", err)
51+
return
52+
}
53+
}()
4954
}
5055
if err := cli.ContainerRemove(ctx, containerInfo.ID, types.ContainerRemoveOptions{Force: true}); err != nil {
5156
_ = utils.LogError(fmt.Sprintf("Unable to remove container %s - %s", containerInfo.ID, err.Error()), nil)

0 commit comments

Comments
 (0)