forked from TrueCloudLab/frostfs-node
[#569] cli: Add control shards writecache seal
command
It does the same as `control shards flush-writecache --seal`, but has better name. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
7a9db5bcdd
commit
581887148a
13 changed files with 1297 additions and 354 deletions
|
@ -56,3 +56,33 @@ func (s *Shard) FlushWriteCache(ctx context.Context, p FlushWriteCachePrm) error
|
|||
|
||||
return s.writeCache.Flush(ctx, p.ignoreErrors, p.seal)
|
||||
}
|
||||
|
||||
type SealWriteCachePrm struct {
|
||||
IgnoreErrors bool
|
||||
}
|
||||
|
||||
// SealWriteCache flushes all data from the write-cache and moves it to degraded read only mode.
|
||||
func (s *Shard) SealWriteCache(ctx context.Context, p SealWriteCachePrm) error {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "Shard.SealWriteCache",
|
||||
trace.WithAttributes(
|
||||
attribute.String("shard_id", s.ID().String()),
|
||||
attribute.Bool("ignore_errors", p.IgnoreErrors),
|
||||
))
|
||||
defer span.End()
|
||||
|
||||
if !s.hasWriteCache() {
|
||||
return errWriteCacheDisabled
|
||||
}
|
||||
|
||||
s.m.RLock()
|
||||
defer s.m.RUnlock()
|
||||
|
||||
if s.info.Mode.ReadOnly() {
|
||||
return ErrReadOnlyMode
|
||||
}
|
||||
if s.info.Mode.NoMetabase() {
|
||||
return ErrDegradedMode
|
||||
}
|
||||
|
||||
return s.writeCache.Seal(ctx, p.IgnoreErrors)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue