forked from TrueCloudLab/frostfs-node
[#162] core: Move literals to constants
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
a5f51add25
commit
21800e9fcc
8 changed files with 33 additions and 17 deletions
|
@ -333,7 +333,7 @@ func (c *cfg) netmapInitLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, bool,
|
||||||
if nmState != candidateState {
|
if nmState != candidateState {
|
||||||
// This happens when the node was switched to maintenance without epoch tick.
|
// This happens when the node was switched to maintenance without epoch tick.
|
||||||
// We expect it to continue staying in maintenance.
|
// We expect it to continue staying in maintenance.
|
||||||
c.log.Info("candidate status is different from the netmap status, the former takes priority",
|
c.log.Info(logs.CandidateStatusPriority,
|
||||||
zap.String("netmap", nmState),
|
zap.String("netmap", nmState),
|
||||||
zap.String("candidate", candidateState))
|
zap.String("candidate", candidateState))
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,6 +495,22 @@ const (
|
||||||
FrostFSNodeNodeIsUnderMaintenanceSkipInitialBootstrap = "the node is under maintenance, skip initial bootstrap"
|
FrostFSNodeNodeIsUnderMaintenanceSkipInitialBootstrap = "the node is under maintenance, skip initial bootstrap"
|
||||||
EngineCouldNotChangeShardModeToDisabled = "could not change shard mode to disabled"
|
EngineCouldNotChangeShardModeToDisabled = "could not change shard mode to disabled"
|
||||||
NetmapNodeAlreadyInCandidateListOnlineSkipInitialBootstrap = "the node is already in candidate list with online state, skip initial bootstrap"
|
NetmapNodeAlreadyInCandidateListOnlineSkipInitialBootstrap = "the node is already in candidate list with online state, skip initial bootstrap"
|
||||||
|
RPConnectionLost = "RPC connection lost, attempting reconnect"
|
||||||
|
RPCNodeSwitchFailure = "can't switch RPC node"
|
||||||
|
FSTreeCantReadFile = "can't read a file"
|
||||||
|
FSTreeCantUnmarshalObject = "can't unmarshal an object"
|
||||||
|
FSTreeCantFushObjectBlobstor = "can't flush an object to blobstor"
|
||||||
|
FSTreeCantUpdateID = "can't update object storage ID"
|
||||||
|
FSTreeCantDecodeDBObjectAddress = "can't decode object address from the DB"
|
||||||
|
PutSingleRedirectFailure = "failed to redirect PutSingle request"
|
||||||
|
StorageIDRetrievalFailure = "can't get storage ID from metabase"
|
||||||
|
ObjectRemovalFailureBlobStor = "can't remove object from blobStor"
|
||||||
|
CandidateStatusPriority = "candidate status is different from the netmap status, the former takes priority"
|
||||||
|
TombstoneExpirationParseFailure = "tombstone getter: could not parse tombstone expiration epoch"
|
||||||
|
FrostFSNodeCantUpdateObjectStorageID = "can't update object storage ID"
|
||||||
|
FrostFSNodeCantFlushObjectToBlobstor = "can't flush an object to blobstor"
|
||||||
|
FrostFSNodeCantDecodeObjectAddressFromDB = "can't decode object address from the DB" // Error in ../node/cmd/frostfs-node/morph.go
|
||||||
|
FrostFSNodeCantUnmarshalObjectFromDB = "can't unmarshal an object from the DB" // Error in ../node/cmd/frostfs-node/morph.go
|
||||||
RuntimeSoftMemoryLimitUpdated = "soft runtime memory limit value updated"
|
RuntimeSoftMemoryLimitUpdated = "soft runtime memory limit value updated"
|
||||||
RuntimeSoftMemoryDefinedWithGOMEMLIMIT = "soft runtime memory defined with GOMEMLIMIT environment variable, config value skipped"
|
RuntimeSoftMemoryDefinedWithGOMEMLIMIT = "soft runtime memory defined with GOMEMLIMIT environment variable, config value skipped"
|
||||||
)
|
)
|
||||||
|
|
|
@ -92,7 +92,7 @@ func (s *Shard) deleteFromBlobstorSafe(ctx context.Context, addr oid.Address) {
|
||||||
|
|
||||||
res, err := s.metaBase.StorageID(ctx, sPrm)
|
res, err := s.metaBase.StorageID(ctx, sPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Debug("can't get storage ID from metabase",
|
s.log.Debug(logs.StorageIDRetrievalFailure,
|
||||||
zap.Stringer("object", addr),
|
zap.Stringer("object", addr),
|
||||||
zap.String("error", err.Error()))
|
zap.String("error", err.Error()))
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (s *Shard) deleteFromBlobstorSafe(ctx context.Context, addr oid.Address) {
|
||||||
|
|
||||||
_, err = s.blobStor.Delete(ctx, delPrm)
|
_, err = s.blobStor.Delete(ctx, delPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Debug("can't remove object from blobStor",
|
s.log.Debug(logs.ObjectRemovalFailureBlobStor,
|
||||||
zap.Stringer("object_address", addr),
|
zap.Stringer("object_address", addr),
|
||||||
zap.String("error", err.Error()))
|
zap.String("error", err.Error()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ func (c *cache) flushObject(ctx context.Context, obj *objectSDK.Object, data []b
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.Is(err, common.ErrNoSpace) && !errors.Is(err, common.ErrReadOnly) &&
|
if !errors.Is(err, common.ErrNoSpace) && !errors.Is(err, common.ErrReadOnly) &&
|
||||||
!errors.Is(err, blobstor.ErrNoPlaceFound) {
|
!errors.Is(err, blobstor.ErrNoPlaceFound) {
|
||||||
c.reportFlushError("can't flush an object to blobstor",
|
c.reportFlushError(logs.FrostFSNodeCantFlushObjectToBlobstor,
|
||||||
addr.EncodeToString(), err)
|
addr.EncodeToString(), err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -200,7 +200,7 @@ func (c *cache) flushObject(ctx context.Context, obj *objectSDK.Object, data []b
|
||||||
|
|
||||||
_, err = c.metabase.UpdateStorageID(updPrm)
|
_, err = c.metabase.UpdateStorageID(updPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.reportFlushError("can't update object storage ID",
|
c.reportFlushError(logs.FrostFSNodeCantUpdateObjectStorageID,
|
||||||
addr.EncodeToString(), err)
|
addr.EncodeToString(), err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -230,7 +230,7 @@ func (c *cache) flush(ctx context.Context, ignoreErrors bool) error {
|
||||||
for it.Rewind(); it.Valid(); it.Next() {
|
for it.Rewind(); it.Valid(); it.Next() {
|
||||||
if got, want := int(it.Item().KeySize()), len(key); got != want {
|
if got, want := int(it.Item().KeySize()), len(key); got != want {
|
||||||
err := fmt.Errorf("invalid db key len: got %d, want %d", got, want)
|
err := fmt.Errorf("invalid db key len: got %d, want %d", got, want)
|
||||||
c.reportFlushError("can't decode object address from the DB", hex.EncodeToString(it.Item().Key()), metaerr.Wrap(err))
|
c.reportFlushError(logs.FrostFSNodeCantDecodeObjectAddressFromDB, hex.EncodeToString(it.Item().Key()), metaerr.Wrap(err))
|
||||||
if ignoreErrors {
|
if ignoreErrors {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ func (c *cache) flush(ctx context.Context, ignoreErrors bool) error {
|
||||||
var obj objectSDK.Object
|
var obj objectSDK.Object
|
||||||
if err := obj.Unmarshal(data); err != nil {
|
if err := obj.Unmarshal(data); err != nil {
|
||||||
copy(key[:], it.Item().Key())
|
copy(key[:], it.Item().Key())
|
||||||
c.reportFlushError("can't unmarshal an object from the DB", key.address().EncodeToString(), metaerr.Wrap(err))
|
c.reportFlushError(logs.FrostFSNodeCantUnmarshalObjectFromDB, key.address().EncodeToString(), metaerr.Wrap(err))
|
||||||
if ignoreErrors {
|
if ignoreErrors {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ func (c *cache) flushFSTree(ctx context.Context, ignoreErrors bool) error {
|
||||||
|
|
||||||
data, err := f()
|
data, err := f()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.reportFlushError("can't read a file", sAddr, metaerr.Wrap(err))
|
c.reportFlushError(logs.FSTreeCantReadFile, sAddr, metaerr.Wrap(err))
|
||||||
if ignoreErrors {
|
if ignoreErrors {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ func (c *cache) flushFSTree(ctx context.Context, ignoreErrors bool) error {
|
||||||
var obj objectSDK.Object
|
var obj objectSDK.Object
|
||||||
err = obj.Unmarshal(data)
|
err = obj.Unmarshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.reportFlushError("can't unmarshal an object", sAddr, metaerr.Wrap(err))
|
c.reportFlushError(logs.FSTreeCantUnmarshalObject, sAddr, metaerr.Wrap(err))
|
||||||
if ignoreErrors {
|
if ignoreErrors {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ func (c *cache) flushObject(ctx context.Context, obj *objectSDK.Object, data []b
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.Is(err, common.ErrNoSpace) && !errors.Is(err, common.ErrReadOnly) &&
|
if !errors.Is(err, common.ErrNoSpace) && !errors.Is(err, common.ErrReadOnly) &&
|
||||||
!errors.Is(err, blobstor.ErrNoPlaceFound) {
|
!errors.Is(err, blobstor.ErrNoPlaceFound) {
|
||||||
c.reportFlushError("can't flush an object to blobstor",
|
c.reportFlushError(logs.FSTreeCantFushObjectBlobstor,
|
||||||
addr.EncodeToString(), err)
|
addr.EncodeToString(), err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -280,7 +280,7 @@ func (c *cache) flushObject(ctx context.Context, obj *objectSDK.Object, data []b
|
||||||
|
|
||||||
_, err = c.metabase.UpdateStorageID(updPrm)
|
_, err = c.metabase.UpdateStorageID(updPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.reportFlushError("can't update object storage ID",
|
c.reportFlushError(logs.FSTreeCantUpdateID,
|
||||||
addr.EncodeToString(), err)
|
addr.EncodeToString(), err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -315,7 +315,7 @@ func (c *cache) flush(ctx context.Context, ignoreErrors bool) error {
|
||||||
for k, data := cs.Seek(nil); k != nil; k, data = cs.Next() {
|
for k, data := cs.Seek(nil); k != nil; k, data = cs.Next() {
|
||||||
sa := string(k)
|
sa := string(k)
|
||||||
if err := addr.DecodeString(sa); err != nil {
|
if err := addr.DecodeString(sa); err != nil {
|
||||||
c.reportFlushError("can't decode object address from the DB", sa, metaerr.Wrap(err))
|
c.reportFlushError(logs.FSTreeCantDecodeDBObjectAddress, sa, metaerr.Wrap(err))
|
||||||
if ignoreErrors {
|
if ignoreErrors {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ func (c *cache) flush(ctx context.Context, ignoreErrors bool) error {
|
||||||
|
|
||||||
var obj objectSDK.Object
|
var obj objectSDK.Object
|
||||||
if err := obj.Unmarshal(data); err != nil {
|
if err := obj.Unmarshal(data); err != nil {
|
||||||
c.reportFlushError("can't unmarshal an object from the DB", sa, metaerr.Wrap(err))
|
c.reportFlushError(logs.FSTreeCantDecodeDBObjectAddress, sa, metaerr.Wrap(err))
|
||||||
if ignoreErrors {
|
if ignoreErrors {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,9 +250,9 @@ routeloop:
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *subscriber) switchEndpoint(ctx context.Context, finishCh chan<- bool) (bool, <-chan rpcclient.Notification) {
|
func (s *subscriber) switchEndpoint(ctx context.Context, finishCh chan<- bool) (bool, <-chan rpcclient.Notification) {
|
||||||
s.log.Info("RPC connection lost, attempting reconnect")
|
s.log.Info(logs.RPConnectionLost)
|
||||||
if !s.client.SwitchRPC(ctx) {
|
if !s.client.SwitchRPC(ctx) {
|
||||||
s.log.Error("can't switch RPC node")
|
s.log.Error(logs.RPCNodeSwitchFailure)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ func (s *Service) redirectPutSingleRequest(ctx context.Context,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
objID, _ := obj.ID()
|
objID, _ := obj.ID()
|
||||||
cnrID, _ := obj.ContainerID()
|
cnrID, _ := obj.ContainerID()
|
||||||
s.log.Warn("failed to redirect PutSingle request",
|
s.log.Warn(logs.PutSingleRedirectFailure,
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
zap.Stringer("address", addr),
|
zap.Stringer("address", addr),
|
||||||
zap.Stringer("object_id", objID),
|
zap.Stringer("object_id", objID),
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (g *ExpirationChecker) handleTS(addr string, ts *objectSDK.Object, reqEpoch
|
||||||
epoch, err := strconv.ParseUint(atr.Value(), 10, 64)
|
epoch, err := strconv.ParseUint(atr.Value(), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.log.Warn(
|
g.log.Warn(
|
||||||
"tombstone getter: could not parse tombstone expiration epoch",
|
logs.TombstoneExpirationParseFailure,
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue