Skip to content

Commit

Permalink
Removes unnecessary error messages when merging two lists
Browse files Browse the repository at this point in the history
  • Loading branch information
igooch committed Oct 30, 2023
1 parent 12971d4 commit 911aee2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions pkg/apis/agones/v1/gameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,14 +937,7 @@ func (gs *GameServer) AppendListValues(name string, values []string) error {
}
if list, ok := gs.Status.Lists[name]; ok {
mergedList := MergeRemoveDuplicates(list.Values, values)
if len(mergedList) > int(list.Capacity) {
return errors.Errorf("unable to AppendListValues: Name %s, Values %s. Appended list length %d exceeds list capacity %d", name, values, len(mergedList), list.Capacity)
}
// If all given values are duplicates we give an error warning.
if len(mergedList) == len(list.Values) {
return errors.Errorf("unable to AppendListValues: Name %s, Values %s. All appended values are duplicates of the existing list", name, values)
}
// If only some values are duplicates, those duplicate values are silently dropped.
// Any duplicate values are silently dropped.
list.Values = mergedList
// Truncate values if more than capacity
if len(list.Values) > int(list.Capacity) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gameserverallocations/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestAllocatorApplyAllocationToGameServerCountsListsActions(t *testing.T) {
}},
wantLists: map[string]agonesv1.ListStatus{
"players": {
Values: []string{},
Values: []string{"x7un"},
Capacity: 1,
}},
},
Expand Down

0 comments on commit 911aee2

Please sign in to comment.