Skip to content

Commit

Permalink
fix(worker): debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
fsamin authored and richardlt committed Jan 17, 2020
1 parent 9489b1b commit cc5a873
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions engine/worker/internal/action/builtin_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ func writeScriptContent(ctx context.Context, script *script, fs afero.Fs, basedi
script.opts = append(script.opts, realScriptPath)
}

log.Debug("writeScriptContent> script is %s", realScriptPath)
log.Debug("writeScriptContent> script.dir is %s", script.dir)
log.Debug("writeScriptContent> script realpath is %s", realScriptPath)
log.Debug("writeScriptContent> script directory is %s", script.dir)

deferFunc := func() {
filename := filepath.Join(path.Dir(basedir.Name()), tmpFileName)
Expand Down
13 changes: 10 additions & 3 deletions engine/worker/internal/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ func setupWorkingDirectory(ctx context.Context, fs afero.Fs, wd string) (afero.F
return fi, nil
}

func teardownDirectory(fs afero.Fs, wd string) error {
return fs.RemoveAll(wd)
func teardownDirectory(fs afero.Fs, dir string) error {
return fs.RemoveAll(dir)
}

func workingDirectory(ctx context.Context, fs afero.Fs, jobInfo sdk.WorkflowNodeJobRunData, suffixes ...string) (string, error) {
Expand Down Expand Up @@ -538,11 +538,18 @@ func (w *CurrentWorker) ProcessJob(jobInfo sdk.WorkflowNodeJobRunData) (sdk.Resu
log.Debug("processJob> new variables: %v", res.NewVariables)
}

// Delete working directory
if err := teardownDirectory(w.basedir, wdFile.Name()); err != nil {
log.Error(ctx, "Cannot remove build directory: %s", err)
}
if err := teardownDirectory(w.basedir, wdFile.Name()); err != nil {
// Delelete key directory
if err := teardownDirectory(w.basedir, kdFile.Name()); err != nil {
log.Error(ctx, "Cannot remove keys directory: %s", err)
}
// Delete all plugins
if err := teardownDirectory(w.basedir, ""); err != nil {
log.Error(ctx, "Cannot remove basedir content: %s", err)
}

return res, err
}

0 comments on commit cc5a873

Please sign in to comment.