Skip to content

Commit

Permalink
node: don't mkdir random paths from configuration
Browse files Browse the repository at this point in the history
Unbreak peapods:
  2023/09/13 18:50:36 open shard S4wpuCnzpWW7SbwhER3U1v: could not open *blobstor.BlobStor: open substorage peapod: open BoltDB instance: open /storage/peapod0.db: is a directory

Call `stat()` gently instead walking up. FS mount point has to exist there in
any event and we should have some access to it.

The real problem is that #2462 (introducing Peapod) was correct on its own.
And #2495 (introducing capacity) was also correct on its own. But they don't
work together.

Refs 7c54307.
Refs c060b16.

util.MkdirAllX will be removed from code in most of the cases.

Signed-off-by: Roman Khimov <[email protected]>
  • Loading branch information
roman-khimov committed Sep 14, 2023
1 parent 22559a9 commit c75f18b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog for NeoFS Node
## [Unreleased]

### Fixed
- Inability to start node with peapods configured (#2576)

### Removed

Expand Down
18 changes: 14 additions & 4 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"context"
"errors"
"fmt"
"io/fs"
"net"
"os"
"os/signal"
"path/filepath"
"sync"
atomicstd "sync/atomic"
"syscall"
Expand Down Expand Up @@ -932,12 +934,20 @@ func writeSystemAttributes(c *cfg) error {
for _, sh := range c.applicationConfiguration.EngineCfg.shards {
for _, subStorage := range sh.SubStorages {
path := subStorage.Path
paths = append(paths, path)

err := util.MkdirAllX(path, subStorage.Perm)
if err != nil {
return fmt.Errorf("can not create (ensure it exists) dir by '%s' path: %w", path, err)
for len(path) > 1 { // Dir returns / or . if nothing else left.
fi, err := os.Stat(path)
if err == nil && fi.IsDir() {
break
}
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("accessing %q: %w", path, err)
}
path = filepath.Dir(path)
}

paths = append(paths, path)

Check failure on line 950 in cmd/neofs-node/config.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)
}
}

Expand Down

0 comments on commit c75f18b

Please sign in to comment.