[#1415] lens/explorer: Add timeout for opening database
All checks were successful
DCO action / DCO (pull_request) Successful in 2m16s
Vulncheck / Vulncheck (pull_request) Successful in 2m14s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m51s
Build / Build Components (pull_request) Successful in 2m54s
Tests and linters / gopls check (pull_request) Successful in 3m25s
Tests and linters / Lint (pull_request) Successful in 4m2s
Tests and linters / Staticcheck (pull_request) Successful in 4m4s
Tests and linters / Run gofumpt (pull_request) Successful in 3m58s
Tests and linters / Tests (pull_request) Successful in 6m16s
Tests and linters / Tests with -race (pull_request) Successful in 6m54s
All checks were successful
DCO action / DCO (pull_request) Successful in 2m16s
Vulncheck / Vulncheck (pull_request) Successful in 2m14s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m51s
Build / Build Components (pull_request) Successful in 2m54s
Tests and linters / gopls check (pull_request) Successful in 3m25s
Tests and linters / Lint (pull_request) Successful in 4m2s
Tests and linters / Staticcheck (pull_request) Successful in 4m4s
Tests and linters / Run gofumpt (pull_request) Successful in 3m58s
Tests and linters / Tests (pull_request) Successful in 6m16s
Tests and linters / Tests with -race (pull_request) Successful in 6m54s
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
a5de74a249
commit
14c5c466db
4 changed files with 16 additions and 36 deletions
|
@ -9,7 +9,6 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/tui"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/tui"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.etcd.io/bbolt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var tuiCMD = &cobra.Command{
|
var tuiCMD = &cobra.Command{
|
||||||
|
@ -43,7 +42,7 @@ func tuiFunc(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTUI(cmd *cobra.Command) error {
|
func runTUI(cmd *cobra.Command) error {
|
||||||
db, err := openDB(false)
|
db, err := tui.OpenDB(vPath, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("couldn't open database: %w", err)
|
return fmt.Errorf("couldn't open database: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -67,13 +66,3 @@ func runTUI(cmd *cobra.Command) error {
|
||||||
app.SetRoot(ui, true).SetFocus(ui)
|
app.SetRoot(ui, true).SetFocus(ui)
|
||||||
return app.Run()
|
return app.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func openDB(writable bool) (*bbolt.DB, error) {
|
|
||||||
db, err := bbolt.Open(vPath, 0o600, &bbolt.Options{
|
|
||||||
ReadOnly: !writable,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return db, nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/tui"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/tui"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.etcd.io/bbolt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var tuiCMD = &cobra.Command{
|
var tuiCMD = &cobra.Command{
|
||||||
|
@ -44,7 +43,7 @@ func tuiFunc(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTUI(cmd *cobra.Command) error {
|
func runTUI(cmd *cobra.Command) error {
|
||||||
db, err := openDB(false)
|
db, err := tui.OpenDB(vPath, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("couldn't open database: %w", err)
|
return fmt.Errorf("couldn't open database: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -70,13 +69,3 @@ func runTUI(cmd *cobra.Command) error {
|
||||||
app.SetRoot(ui, true).SetFocus(ui)
|
app.SetRoot(ui, true).SetFocus(ui)
|
||||||
return app.Run()
|
return app.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func openDB(writable bool) (*bbolt.DB, error) {
|
|
||||||
db, err := bbolt.Open(vPath, 0o600, &bbolt.Options{
|
|
||||||
ReadOnly: !writable,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return db, nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,12 +3,25 @@ package tui
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"github.com/mr-tron/base58"
|
"github.com/mr-tron/base58"
|
||||||
|
"go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func OpenDB(path string, writable bool) (*bbolt.DB, error) {
|
||||||
|
db, err := bbolt.Open(path, 0o600, &bbolt.Options{
|
||||||
|
ReadOnly: !writable,
|
||||||
|
Timeout: 100 * time.Microsecond,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return db, nil
|
||||||
|
}
|
||||||
|
|
||||||
func CIDParser(s string) (any, error) {
|
func CIDParser(s string) (any, error) {
|
||||||
data, err := base58.Decode(s)
|
data, err := base58.Decode(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/tui"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal/tui"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.etcd.io/bbolt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var tuiCMD = &cobra.Command{
|
var tuiCMD = &cobra.Command{
|
||||||
|
@ -43,7 +42,7 @@ func tuiFunc(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTUI(cmd *cobra.Command) error {
|
func runTUI(cmd *cobra.Command) error {
|
||||||
db, err := openDB(false)
|
db, err := tui.OpenDB(vPath, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("couldn't open database: %w", err)
|
return fmt.Errorf("couldn't open database: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -67,13 +66,3 @@ func runTUI(cmd *cobra.Command) error {
|
||||||
app.SetRoot(ui, true).SetFocus(ui)
|
app.SetRoot(ui, true).SetFocus(ui)
|
||||||
return app.Run()
|
return app.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func openDB(writable bool) (*bbolt.DB, error) {
|
|
||||||
db, err := bbolt.Open(vPath, 0o600, &bbolt.Options{
|
|
||||||
ReadOnly: !writable,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return db, nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue