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

node: don't mkdir random paths from configuration #2576

Merged
merged 1 commit into from
Sep 14, 2023
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
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
17 changes: 13 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,19 @@ 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)
}
}

Expand Down
Loading