Skip to content

Commit

Permalink
Added storage limits (#28270)
Browse files Browse the repository at this point in the history
  • Loading branch information
divyaac authored Sep 10, 2024
1 parent 3924128 commit 582035e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion vault/logical_system_activity_write_testonly.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,19 @@ func (s *singleMonthActivityClients) populateSegments() (map[int][]*activity.Ent
return segments, nil
}

totalSegmentCount := 1
// determine how many segments are necessary to store the clients for this month
// using the default storage limits
numNecessarySegments := len(s.clients) / ActivitySegmentClientCapacity
if len(s.clients)%ActivitySegmentClientCapacity != 0 {
numNecessarySegments++
}
totalSegmentCount := numNecessarySegments

// override the segment count if set by client
if s.generationParameters.GetNumSegments() > 0 {
totalSegmentCount = int(s.generationParameters.GetNumSegments())
}

numNonUsable := len(skipIndexes) + len(emptyIndexes)
usableSegmentCount := totalSegmentCount - numNonUsable
if usableSegmentCount <= 0 {
Expand All @@ -169,6 +178,10 @@ func (s *singleMonthActivityClients) populateSegments() (map[int][]*activity.Ent
segmentSizes++
}

if segmentSizes > ActivitySegmentClientCapacity {
return nil, fmt.Errorf("the number of segments is too low, it must be greater than %d in order to meet storage limits", numNecessarySegments)
}

clientIndex := 0
for i := 0; i < totalSegmentCount; i++ {
if clientIndex >= len(s.clients) {
Expand Down

0 comments on commit 582035e

Please sign in to comment.