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

Add job source bucket to output path #1101

Merged
merged 3 commits into from
Aug 2, 2022
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
2 changes: 1 addition & 1 deletion cmd/etl_worker/etl_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestLocalRequest(t *testing.T) {
}

// Check the outdir for the successful content of a localwriter.
p := filepath.Join(outdir, "ndt/ndt7/2021/06/17/20210617T003002.410133Z-ndt7-mlab1-foo01-ndt.tgz.jsonl")
p := filepath.Join(outdir, "archive-mlab-testing/ndt/ndt7/2021/06/17/20210617T003002.410133Z-ndt7-mlab1-foo01-ndt.tgz.jsonl")
f, err := os.Open(p)
if err != nil {
t.Fatalf("failed to read file: %v", err)
Expand Down
3 changes: 2 additions & 1 deletion storage/localwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"path"
"path/filepath"

"github.com/m-lab/etl/etl"
Expand Down Expand Up @@ -84,7 +85,7 @@ type LocalFactory struct {

// Get implements factory.SinkFactory for LocalWriters.
func (lf *LocalFactory) Get(ctx context.Context, dp etl.DataPath) (row.Sink, etl.ProcessingError) {
s, err := NewLocalWriter(lf.outputDir, dp.Path+".jsonl")
s, err := NewLocalWriter(lf.outputDir, path.Join(dp.Bucket, dp.Path+".jsonl"))
if err != nil {
return nil, factory.NewError(dp.DataType, "LocalFactory", http.StatusInternalServerError, err)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/localwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestNewLocalFactory(t *testing.T) {
if tt.wantOpenErr {
// Make directory so open will fail.
err := os.MkdirAll(filepath.Join(tt.outputDir,
"exp/ndt7/2021/06/01/20210601T101003.000001Z-ndt7-mlab4-foo01-exp.tgz.jsonl"), os.ModePerm)
"bucket/exp/ndt7/2021/06/01/20210601T101003.000001Z-ndt7-mlab4-foo01-exp.tgz.jsonl"), os.ModePerm)
testingx.Must(t, err, "failed to mkdir")
}

Expand Down
3 changes: 2 additions & 1 deletion storage/rowwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log"
"net/http"
"path"
"time"

gcs "cloud.google.com/go/storage"
Expand Down Expand Up @@ -177,7 +178,7 @@ type SinkFactory struct {

// Get implements factory.SinkFactory
func (sf *SinkFactory) Get(ctx context.Context, dp etl.DataPath) (row.Sink, etl.ProcessingError) {
s, err := NewRowWriter(ctx, sf.client, sf.outputBucket, dp.Path+".json")
s, err := NewRowWriter(ctx, sf.client, sf.outputBucket, path.Join(dp.Bucket, dp.Path+".jsonl"))
if err != nil {
return nil, factory.NewError(dp.DataType, "SinkFactory",
http.StatusInternalServerError, err)
Expand Down
2 changes: 1 addition & 1 deletion worker/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestProcessGKETask(t *testing.T) {
checkCounter(t, c, 478)

// Lookup output from task.
o, err := fs.GetObject("test-bucket", "ndt/ndt5/2019/12/01/20191201T020011.395772Z-ndt5-mlab1-bcn01-ndt.tgz.json")
o, err := fs.GetObject("test-bucket", "test-bucket/ndt/ndt5/2019/12/01/20191201T020011.395772Z-ndt5-mlab1-bcn01-ndt.tgz.jsonl")
if err != nil {
t.Errorf("GetObject() expected nil error, got %v", err)
}
Expand Down