Skip to content

Commit

Permalink
Merge pull request #8764 from influxdata/dn-8638-influx_inspect
Browse files Browse the repository at this point in the history
fix #8638: inspect shouldn't err on missing file
  • Loading branch information
dgnorton authored Aug 30, 2017
2 parents dd01132 + 2aa446b commit 0da7116
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- [#8699](https://github.com/influxdata/influxdb/issues/8699): Force subqueries to match the parent queries ordering.
- [#8755](https://github.com/influxdata/influxdb/pull/8755): Fix race condition accessing `seriesByID` map.
- [#8766](https://github.com/influxdata/influxdb/pull/8766): Fix deadlock when calling `SeriesIDsAllOrByExpr`
- [#8638](https://github.com/influxdata/influxdb/issues/8638): Fix `influx_inspect export` so it skips missing files.

## v1.3.4 [unreleased]

Expand Down
8 changes: 8 additions & 0 deletions cmd/influx_inspect/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ func (cmd *Command) writeTsmFiles(w io.Writer, files []string) error {
func (cmd *Command) exportTSMFile(tsmFilePath string, w io.Writer) error {
f, err := os.Open(tsmFilePath)
if err != nil {
if os.IsNotExist(err) {
fmt.Fprintf(w, "skipped missing file: %s", tsmFilePath)
return nil
}
return err
}
defer f.Close()
Expand Down Expand Up @@ -325,6 +329,10 @@ or manually editing the exported file.
func (cmd *Command) exportWALFile(walFilePath string, w io.Writer, warnDelete func()) error {
f, err := os.Open(walFilePath)
if err != nil {
if os.IsNotExist(err) {
fmt.Fprintf(w, "skipped missing file: %s", walFilePath)
return nil
}
return err
}
defer f.Close()
Expand Down
12 changes: 12 additions & 0 deletions cmd/influx_inspect/export/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ func Test_exportWALFile(t *testing.T) {
}
}
}

// Missing .wal file should not cause a failure.
var out bytes.Buffer
if err := newCommand().exportWALFile("file-that-does-not-exist.wal", &out, func() {}); err != nil {
t.Fatal(err)
}
}

func Test_exportTSMFile(t *testing.T) {
Expand Down Expand Up @@ -128,6 +134,12 @@ func Test_exportTSMFile(t *testing.T) {
}
}
}

// Missing .tsm file should not cause a failure.
var out bytes.Buffer
if err := newCommand().exportTSMFile("file-that-does-not-exist.tsm", &out); err != nil {
t.Fatal(err)
}
}

var sink interface{}
Expand Down

0 comments on commit 0da7116

Please sign in to comment.