Skip to content

Commit 582035e

Browse files
authored
Added storage limits (#28270)
1 parent 3924128 commit 582035e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

vault/logical_system_activity_write_testonly.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,19 @@ func (s *singleMonthActivityClients) populateSegments() (map[int][]*activity.Ent
153153
return segments, nil
154154
}
155155

156-
totalSegmentCount := 1
156+
// determine how many segments are necessary to store the clients for this month
157+
// using the default storage limits
158+
numNecessarySegments := len(s.clients) / ActivitySegmentClientCapacity
159+
if len(s.clients)%ActivitySegmentClientCapacity != 0 {
160+
numNecessarySegments++
161+
}
162+
totalSegmentCount := numNecessarySegments
163+
164+
// override the segment count if set by client
157165
if s.generationParameters.GetNumSegments() > 0 {
158166
totalSegmentCount = int(s.generationParameters.GetNumSegments())
159167
}
168+
160169
numNonUsable := len(skipIndexes) + len(emptyIndexes)
161170
usableSegmentCount := totalSegmentCount - numNonUsable
162171
if usableSegmentCount <= 0 {
@@ -169,6 +178,10 @@ func (s *singleMonthActivityClients) populateSegments() (map[int][]*activity.Ent
169178
segmentSizes++
170179
}
171180

181+
if segmentSizes > ActivitySegmentClientCapacity {
182+
return nil, fmt.Errorf("the number of segments is too low, it must be greater than %d in order to meet storage limits", numNecessarySegments)
183+
}
184+
172185
clientIndex := 0
173186
for i := 0; i < totalSegmentCount; i++ {
174187
if clientIndex >= len(s.clients) {

0 commit comments

Comments
 (0)