satellite/metainfo: UpdateProjectSegmentUsage enabled only with segment validation
updating project segment usage entry to redis is enabled only if segment validation is enabled in config value, so no incompatible changes will be added while deployment. Change-Id: I1288cb9ff0a8a00f095dc94e20d2f14393e9a613
This commit is contained in:
parent
3a987ac00f
commit
18ab464b51
@ -1977,21 +1977,23 @@ func (endpoint *Endpoint) CommitSegment(ctx context.Context, req *pb.SegmentComm
|
||||
return nil, endpoint.convertMetabaseErr(err)
|
||||
}
|
||||
|
||||
// Update the current segment cache value incrementing by 1 as we commit single segment.
|
||||
err = endpoint.projectUsage.UpdateProjectSegmentUsage(ctx, keyInfo.ProjectID, 1)
|
||||
if err != nil {
|
||||
if errs2.IsCanceled(err) {
|
||||
return nil, rpcstatus.Wrap(rpcstatus.Canceled, err)
|
||||
}
|
||||
if endpoint.config.ProjectLimits.ValidateSegmentLimit {
|
||||
// Update the current segment cache value incrementing by 1 as we commit single segment.
|
||||
err = endpoint.projectUsage.UpdateProjectSegmentUsage(ctx, keyInfo.ProjectID, 1)
|
||||
if err != nil {
|
||||
if errs2.IsCanceled(err) {
|
||||
return nil, rpcstatus.Wrap(rpcstatus.Canceled, err)
|
||||
}
|
||||
|
||||
// log it and continue. it's most likely our own fault that we couldn't
|
||||
// track it, and the only thing that will be affected is our per-project
|
||||
// segment limits.
|
||||
endpoint.log.Error(
|
||||
"Could not track the new project's segment usage when committing segment",
|
||||
zap.Stringer("Project ID", keyInfo.ProjectID),
|
||||
zap.Error(err),
|
||||
)
|
||||
// log it and continue. it's most likely our own fault that we couldn't
|
||||
// track it, and the only thing that will be affected is our per-project
|
||||
// segment limits.
|
||||
endpoint.log.Error(
|
||||
"Could not track the new project's segment usage when committing segment",
|
||||
zap.Stringer("Project ID", keyInfo.ProjectID),
|
||||
zap.Error(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return &pb.SegmentCommitResponse{
|
||||
@ -2113,21 +2115,23 @@ func (endpoint *Endpoint) MakeInlineSegment(ctx context.Context, req *pb.Segment
|
||||
endpoint.log.Info("Inline Segment Upload", zap.Stringer("Project ID", keyInfo.ProjectID), zap.String("operation", "put"), zap.String("type", "inline"))
|
||||
mon.Meter("req_put_inline").Mark(1)
|
||||
|
||||
// Update the current segment cache value incrementing by 1 as we commit single segment.
|
||||
err = endpoint.projectUsage.UpdateProjectSegmentUsage(ctx, keyInfo.ProjectID, 1)
|
||||
if err != nil {
|
||||
if errs2.IsCanceled(err) {
|
||||
return nil, rpcstatus.Wrap(rpcstatus.Canceled, err)
|
||||
}
|
||||
if endpoint.config.ProjectLimits.ValidateSegmentLimit {
|
||||
// Update the current segment cache value incrementing by 1 as we commit single segment.
|
||||
err = endpoint.projectUsage.UpdateProjectSegmentUsage(ctx, keyInfo.ProjectID, 1)
|
||||
if err != nil {
|
||||
if errs2.IsCanceled(err) {
|
||||
return nil, rpcstatus.Wrap(rpcstatus.Canceled, err)
|
||||
}
|
||||
|
||||
// log it and continue. it's most likely our own fault that we couldn't
|
||||
// track it, and the only thing that will be affected is our per-project
|
||||
// segment limits.
|
||||
endpoint.log.Error(
|
||||
"Could not track the new project's segment usage when committing segment",
|
||||
zap.Stringer("Project ID", keyInfo.ProjectID),
|
||||
zap.Error(err),
|
||||
)
|
||||
// log it and continue. it's most likely our own fault that we couldn't
|
||||
// track it, and the only thing that will be affected is our per-project
|
||||
// segment limits.
|
||||
endpoint.log.Error(
|
||||
"Could not track the new project's segment usage when committing segment",
|
||||
zap.Stringer("Project ID", keyInfo.ProjectID),
|
||||
zap.Error(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return &pb.SegmentMakeInlineResponse{}, nil
|
||||
|
Loading…
Reference in New Issue
Block a user