Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix debug files #712

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pkg/pipeline/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,19 @@ func (c *Controller) uploadDebugFiles() {
}

func (c *Controller) uploadTrackFiles(u uploader.Uploader) {
var dir string
if c.Debug.ToUploadConfig() == nil {
dir = c.Debug.PathPrefix
} else {
dir = c.TmpDir
return
}

files, err := os.ReadDir(dir)
files, err := os.ReadDir(c.TmpDir)
if err != nil {
return
}

for _, f := range files {
if strings.HasSuffix(f.Name(), ".csv") {
local := path.Join(dir, f.Name())
storage := path.Join(c.Debug.PathPrefix, f.Name())
local := path.Join(c.TmpDir, f.Name())
storage := path.Join(c.Debug.PathPrefix, c.Info.EgressId, f.Name())
_, _, err = u.Upload(local, storage, types.OutputTypeBlob, false, "track")
if err != nil {
logger.Errorw("failed to upload debug file", err)
Expand All @@ -121,17 +118,16 @@ func (c *Controller) uploadPProf(u uploader.Uploader) {
}

func (c *Controller) uploadDebugFile(u uploader.Uploader, data []byte, fileExtension string) {
storageDir := path.Join(c.Debug.PathPrefix, c.Info.EgressId)
var dir string
if c.Debug.ToUploadConfig() == nil {
dir = c.Debug.PathPrefix
dir = storageDir
} else {
dir = c.TmpDir
}

filename := fmt.Sprintf("%s%s", c.Info.EgressId, fileExtension)
local := path.Join(dir, filename)
storage := path.Join(c.Debug.PathPrefix, c.Info.EgressId, filename)

f, err := os.Create(local)
if err != nil {
logger.Errorw("failed to create debug file", err)
Expand All @@ -145,7 +141,11 @@ func (c *Controller) uploadDebugFile(u uploader.Uploader, data []byte, fileExten
return
}

_, _, err = u.Upload(local, storage, types.OutputTypeBlob, false, "debug")
if c.Debug.ToUploadConfig() == nil {
return
}

_, _, err = u.Upload(local, path.Join(storageDir, filename), types.OutputTypeBlob, false, "debug")
if err != nil {
logger.Errorw("failed to upload debug file", err)
return
Expand Down
8 changes: 6 additions & 2 deletions pkg/pipeline/source/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package source
import (
"context"
"fmt"
"os"
"path"
"strings"
"sync"
Expand Down Expand Up @@ -489,9 +490,12 @@ func (s *SDKSource) createWriter(
var logFilename string
if s.Debug.EnableProfiling {
if s.Debug.ToUploadConfig() == nil {
logFilename = path.Join(s.Debug.PathPrefix, fmt.Sprintf("%s/%s.csv", s.Info.EgressId, track.ID()))
if err := os.MkdirAll(path.Join(s.Debug.PathPrefix, s.Info.EgressId), 0755); err != nil {
return nil, err
}
logFilename = path.Join(s.Debug.PathPrefix, s.Info.EgressId, fmt.Sprintf("%s.csv", track.ID()))
} else {
logFilename = path.Join(s.TmpDir, fmt.Sprintf("%s/%s.csv", s.Info.EgressId, track.ID()))
logFilename = path.Join(s.TmpDir, fmt.Sprintf("%s.csv", track.ID()))
}
}

Expand Down
Loading