satellite/accounting: update GetProjectSegmentLimit to fix bug
Update GetProjectSegmentLimit to reflect segment limit instead of usage limit. Fixes https://github.com/storj/storj/issues/5713 Change-Id: If4dfc5b45227595f3ae2b3ac7d267ea541fd748a
This commit is contained in:
parent
9d49145570
commit
d8a4ca62b8
@ -91,6 +91,19 @@ func (c *ProjectLimitCache) GetBandwidthLimit(ctx context.Context, projectID uui
|
||||
return memory.Size(*projectLimits.Bandwidth), nil
|
||||
}
|
||||
|
||||
// GetSegmentLimit return the segment limit for a project ID.
|
||||
func (c *ProjectLimitCache) GetSegmentLimit(ctx context.Context, projectID uuid.UUID) (_ memory.Size, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
projectLimits, err := c.GetLimits(ctx, projectID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if projectLimits.Segments == nil {
|
||||
return memory.Size(c.defaultMaxSegments), nil
|
||||
}
|
||||
return memory.Size(*projectLimits.Segments), nil
|
||||
}
|
||||
|
||||
// getProjectLimits returns project limits from DB.
|
||||
func (c *ProjectLimitCache) getProjectLimits(ctx context.Context, projectID uuid.UUID) (_ ProjectLimits, err error) {
|
||||
defer mon.Task()(&ctx, projectID)(&err)
|
||||
|
@ -258,12 +258,7 @@ func (usage *Service) GetProjectBandwidthLimit(ctx context.Context, projectID uu
|
||||
// GetProjectSegmentLimit returns current project segment limit.
|
||||
func (usage *Service) GetProjectSegmentLimit(ctx context.Context, projectID uuid.UUID) (_ memory.Size, err error) {
|
||||
defer mon.Task()(&ctx, projectID)(&err)
|
||||
limits, err := usage.projectLimitCache.GetLimits(ctx, projectID)
|
||||
if err != nil {
|
||||
return 0, ErrProjectUsage.Wrap(err)
|
||||
}
|
||||
|
||||
return memory.Size(*limits.Usage), nil
|
||||
return usage.projectLimitCache.GetSegmentLimit(ctx, projectID)
|
||||
}
|
||||
|
||||
// UpdateProjectLimits sets new value for project's bandwidth and storage limit.
|
||||
|
Loading…
Reference in New Issue
Block a user