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:
Michał Niewrzał 2022-01-13 10:13:10 +01:00
parent 3a987ac00f
commit 18ab464b51

View File

@ -1977,6 +1977,7 @@ func (endpoint *Endpoint) CommitSegment(ctx context.Context, req *pb.SegmentComm
return nil, endpoint.convertMetabaseErr(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 {
@ -1993,6 +1994,7 @@ func (endpoint *Endpoint) CommitSegment(ctx context.Context, req *pb.SegmentComm
zap.Error(err),
)
}
}
return &pb.SegmentCommitResponse{
SuccessfulPieces: int32(len(pieces)),
@ -2113,6 +2115,7 @@ 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)
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 {
@ -2129,6 +2132,7 @@ func (endpoint *Endpoint) MakeInlineSegment(ctx context.Context, req *pb.Segment
zap.Error(err),
)
}
}
return &pb.SegmentMakeInlineResponse{}, nil
}