Skip to content

Commit 072d0f2

Browse files
authored
Tweak local mode (#1027)
* remove O_APPEND from local mode file open * Add README.md and log message to remind about gcloud auth
1 parent f611371 commit 072d0f2

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pipeline. The ETL worker is responsible for parsing data archives produced by
1414

1515
```sh
1616
go get ./cmd/etl_worker
17+
gcloud auth application-default login
1718
~/bin/etl_worker -service_port :8080 -output_dir ./output -output local
1819
```
1920

cmd/etl_worker/etl_worker.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Sample
21
package main
32

43
import (
@@ -187,6 +186,7 @@ func handleLocalRequest(rw http.ResponseWriter, req *http.Request) {
187186
ctx := context.Background()
188187
obj, err := c.Bucket(dp.Bucket).Object(dp.Path).Attrs(ctx)
189188
if err != nil {
189+
log.Println(err)
190190
rw.WriteHeader(http.StatusInternalServerError)
191191
fmt.Fprintf(rw, "failed to get object attrs for %s / %s", dp.Bucket, dp.Path)
192192
return
@@ -407,6 +407,9 @@ func main() {
407407

408408
flag.Parse()
409409
rtx.Must(flagx.ArgsFromEnv(flag.CommandLine), "Could not get args from env")
410+
if outputType.Value == "local" {
411+
log.Println("To resolve oauth problems, run 'gcloud auth application-default login'")
412+
}
410413

411414
go site.MustReload(mainCtx)
412415

storage/localwriter.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ func NewLocalWriter(dir string, path string) (row.Sink, error) {
3131
if err != nil {
3232
return nil, err
3333
}
34-
f, err := os.OpenFile(p, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
34+
// All rows from an archive are appended in a single session, so this
35+
// does not need O_APPEND.
36+
f, err := os.OpenFile(p, os.O_CREATE|os.O_WRONLY, 0644)
3537
if err != nil {
3638
return nil, err
3739
}

0 commit comments

Comments
 (0)