Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added storage limits when writing activity log data in clientcount util #28270

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading