forked from TrueCloudLab/frostfs-node
31 lines
761 B
Go
31 lines
761 B
Go
package writecache
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/trace"
|
|
)
|
|
|
|
func (c *cache) Seal(ctx context.Context, ignoreErrors bool) error {
|
|
ctx, span := tracing.StartSpanFromContext(ctx, "writecache.Seal",
|
|
trace.WithAttributes(
|
|
attribute.Bool("ignore_errors", ignoreErrors),
|
|
))
|
|
defer span.End()
|
|
|
|
c.modeMtx.Lock()
|
|
defer c.modeMtx.Unlock()
|
|
if c.mode.NoMetabase() {
|
|
return ErrDegraded
|
|
}
|
|
|
|
// flush will be done by setMode
|
|
err := c.setMode(ctx, mode.DegradedReadOnly, ignoreErrors)
|
|
if err == nil {
|
|
c.metrics.SetMode(mode.DegradedReadOnly)
|
|
}
|
|
return err
|
|
}
|