[#1974] shard: Do not panic in degraded mode

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-26 09:12:09 +03:00 committed by fyrchik
parent 7395ab8ef7
commit 1e6588e761
8 changed files with 56 additions and 4 deletions

View file

@ -64,6 +64,10 @@ func (r ListWithCursorRes) Cursor() *Cursor {
// List returns all objects physically stored in the Shard.
func (s *Shard) List() (res SelectRes, err error) {
if s.GetMode().NoMetabase() {
return SelectRes{}, ErrDegradedMode
}
lst, err := s.metaBase.Containers()
if err != nil {
return res, fmt.Errorf("can't list stored containers: %w", err)
@ -93,6 +97,10 @@ func (s *Shard) List() (res SelectRes, err error) {
}
func (s *Shard) ListContainers(_ ListContainersPrm) (ListContainersRes, error) {
if s.GetMode().NoMetabase() {
return ListContainersRes{}, ErrDegradedMode
}
containers, err := s.metaBase.Containers()
if err != nil {
return ListContainersRes{}, fmt.Errorf("could not get list of containers: %w", err)