forked from TrueCloudLab/frostfs-node
[#959] node: Set mode to shard's components when open it
Avoid opening database for `metabase` and `cache` in `Degraded` mode. Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
60527abb65
commit
d19ade23c8
25 changed files with 219 additions and 74 deletions
|
@ -6,13 +6,29 @@ import (
|
|||
"fmt"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Open opens BlobStor.
|
||||
func (b *BlobStor) Open(ctx context.Context, readOnly bool) error {
|
||||
func (b *BlobStor) Open(ctx context.Context, mode mode.Mode) error {
|
||||
b.log.Debug(logs.BlobstorOpening)
|
||||
|
||||
b.modeMtx.Lock()
|
||||
defer b.modeMtx.Unlock()
|
||||
b.mode = mode
|
||||
|
||||
err := b.openBlobStor(ctx, mode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.metrics.SetMode(mode.ReadOnly())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *BlobStor) openBlobStor(ctx context.Context, mode mode.Mode) error {
|
||||
readOnly := mode.ReadOnly()
|
||||
for i := range b.storage {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
@ -24,7 +40,6 @@ func (b *BlobStor) Open(ctx context.Context, readOnly bool) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
b.metrics.SetMode(readOnly)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue