From 4894b3d40db183c67bba403d8645709dcd2fb10c Mon Sep 17 00:00:00 2001 From: divyansh42 Date: Fri, 27 Oct 2023 19:03:20 +0530 Subject: [PATCH] Improve stacktrace to fix tech debts Signed-off-by: divyansh42 --- .gitignore | 1 - pkg/docker/docker.go | 10 +++++++++- pkg/scripts/download.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2dc923f12..e110914f3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ /.atom-build.yml /.project /.vagrant -.vscode/ cmd/s2i/debug *~ diff --git a/pkg/docker/docker.go b/pkg/docker/docker.go index 9dc2c0aa8..b0f19ed1a 100644 --- a/pkg/docker/docker.go +++ b/pkg/docker/docker.go @@ -2,6 +2,7 @@ package docker import ( "archive/tar" + "bufio" "bytes" "encoding/base64" "encoding/json" @@ -995,7 +996,14 @@ func (d *stiDocker) RunContainer(opts RunContainerOptions) error { if signal == syscall.SIGQUIT { buf := make([]byte, 1<<16) runtime.Stack(buf, true) - fmt.Printf("%s", buf) + f, err := os.Create("/var/log/s2i_docker_stack_trace.log") + if err != nil { + return + } + defer f.Close() + w := bufio.NewWriter(f) + w.Write(buf) + w.Flush() } os.Exit(2) } diff --git a/pkg/scripts/download.go b/pkg/scripts/download.go index 8e40071d5..1d716b9e1 100644 --- a/pkg/scripts/download.go +++ b/pkg/scripts/download.go @@ -139,7 +139,7 @@ type FileURLReader struct{} func (*FileURLReader) Read(url *url.URL) (io.ReadCloser, error) { // for some reason url.Host may contain information about the ./ or ../ when // specifying relative path, thus using that value as well - return os.Open(filepath.Join(url.Host, url.Path)) + return os.Open(filepath.Clean(filepath.Join(url.Host, url.Path))) } // ImageReader just returns information the URL is from inside the image