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

Changing update list to update list values along with the capacity. #3897

Closed
wants to merge 2 commits into from
Closed
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
34 changes: 34 additions & 0 deletions pkg/sdkserver/sdkserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,40 @@ func (s *SDKServer) UpdateList(ctx context.Context, in *beta.UpdateListRequest)
if _, ok := gs.Status.Lists[name]; ok {
batchList := s.gsListUpdates[name]
batchList.capacitySet = &in.List.Capacity
currList := gs.Status.Lists[name]

// Find values to remove from the current list
valuesToDelete := map[string]bool{}
for _, value := range currList.Values {
valueFound := false
for _, element := range in.List.Values {
if value == element {
valueFound = true
}
}

if !valueFound {
valuesToDelete[value] = true
}
}
batchList.valuesToDelete = valuesToDelete

// Find values that need to be added to the current list from the incomming list
valuesToAdd := []string{}
for _, value := range in.List.Values {
valueFound := false
for _, element := range currList.Values {
if value == element {
valueFound = true
}
}

if !valueFound {
valuesToAdd = append(valuesToAdd, value)
}
}
batchList.valuesToAppend = valuesToAdd

s.gsListUpdates[name] = batchList
// Queue up the Update for later batch processing by updateLists.
s.workerqueue.Enqueue(cache.ExplicitKey(updateLists))
Expand Down
Loading