forked from TrueCloudLab/frostfs-node
[#2057] meta: Fail write operations in R/O mode
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
fdeea1dfac
commit
b1025bdb42
9 changed files with 23 additions and 0 deletions
|
@ -15,6 +15,9 @@ import (
|
||||||
// ErrDegradedMode is returned when metabase is in a degraded mode.
|
// ErrDegradedMode is returned when metabase is in a degraded mode.
|
||||||
var ErrDegradedMode = logicerr.New("metabase is in a degraded mode")
|
var ErrDegradedMode = logicerr.New("metabase is in a degraded mode")
|
||||||
|
|
||||||
|
// ErrReadOnlyMode is returned when metabase is in a read-only mode.
|
||||||
|
var ErrReadOnlyMode = logicerr.New("metabase is in a read-only mode")
|
||||||
|
|
||||||
// Open boltDB instance for metabase.
|
// Open boltDB instance for metabase.
|
||||||
func (db *DB) Open(readOnly bool) error {
|
func (db *DB) Open(readOnly bool) error {
|
||||||
err := util.MkdirAllX(filepath.Dir(db.info.Path), db.info.Permission)
|
err := util.MkdirAllX(filepath.Dir(db.info.Path), db.info.Permission)
|
||||||
|
@ -159,6 +162,8 @@ func (db *DB) SyncCounters() error {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return ErrDegradedMode
|
return ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||||
|
|
|
@ -59,6 +59,8 @@ func (db *DB) Delete(prm DeletePrm) (DeleteRes, error) {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return DeleteRes{}, ErrDegradedMode
|
return DeleteRes{}, ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return DeleteRes{}, ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
var rawRemoved uint64
|
var rawRemoved uint64
|
||||||
|
|
|
@ -237,6 +237,8 @@ func (db *DB) DropGraves(tss []TombstonedObject) error {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return ErrDegradedMode
|
return ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, addressKeySize)
|
buf := make([]byte, addressKeySize)
|
||||||
|
|
|
@ -95,6 +95,8 @@ func (db *DB) Inhume(prm InhumePrm) (res InhumeRes, err error) {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return InhumeRes{}, ErrDegradedMode
|
return InhumeRes{}, ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return InhumeRes{}, ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
currEpoch := db.epochState.CurrentEpoch()
|
currEpoch := db.epochState.CurrentEpoch()
|
||||||
|
|
|
@ -31,6 +31,8 @@ func (db *DB) Lock(cnr cid.ID, locker oid.ID, locked []oid.ID) error {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return ErrDegradedMode
|
return ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(locked) == 0 {
|
if len(locked) == 0 {
|
||||||
|
|
|
@ -54,6 +54,8 @@ func (db *DB) ToMoveIt(prm ToMoveItPrm) (res ToMoveItRes, err error) {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return res, ErrDegradedMode
|
return res, ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return res, ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
key := make([]byte, addressKeySize)
|
key := make([]byte, addressKeySize)
|
||||||
|
@ -74,6 +76,8 @@ func (db *DB) DoNotMove(prm DoNotMovePrm) (res DoNotMoveRes, err error) {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return res, ErrDegradedMode
|
return res, ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return res, ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
key := make([]byte, addressKeySize)
|
key := make([]byte, addressKeySize)
|
||||||
|
|
|
@ -58,6 +58,8 @@ func (db *DB) Put(prm PutPrm) (res PutRes, err error) {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return res, ErrDegradedMode
|
return res, ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return res, ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
currEpoch := db.epochState.CurrentEpoch()
|
currEpoch := db.epochState.CurrentEpoch()
|
||||||
|
|
|
@ -38,6 +38,8 @@ func (db *DB) WriteShardID(id []byte) error {
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return ErrDegradedMode
|
return ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||||
|
|
|
@ -86,6 +86,8 @@ func (db *DB) UpdateStorageID(prm UpdateStorageIDPrm) (res UpdateStorageIDRes, e
|
||||||
|
|
||||||
if db.mode.NoMetabase() {
|
if db.mode.NoMetabase() {
|
||||||
return res, ErrDegradedMode
|
return res, ErrDegradedMode
|
||||||
|
} else if db.mode.ReadOnly() {
|
||||||
|
return res, ErrReadOnlyMode
|
||||||
}
|
}
|
||||||
|
|
||||||
currEpoch := db.epochState.CurrentEpoch()
|
currEpoch := db.epochState.CurrentEpoch()
|
||||||
|
|
Loading…
Reference in a new issue