Fix race in helm list when partitioning

Problem:
The chunks slice that is passed through the channel is reused for each
partition. This means that encoding the release into a message is racing with
populating the next partition, causing the results to sometimes not fit in the
message, and the release list to be incorrect

Solution:
Allocate a new slice for each partition

Issue #3322

Signed-off-by: Brian Marshall <bmarshall13@users.noreply.github.com>
(cherry picked from commit a0858e29d8)
pull/4620/head
Brian Marshall 7 years ago committed by Matthew Fisher
parent 2b33bf6ba7
commit e38f605399
No known key found for this signature in database
GPG Key ID: 92AA783CBAAE8E3B

@ -140,7 +140,7 @@ func (s *ReleaseServer) partition(rels []*release.Release, cap int) <-chan []*re
s.Log("partitioned at %d with %d releases (cap=%d)", fill, len(chunk), cap) s.Log("partitioned at %d with %d releases (cap=%d)", fill, len(chunk), cap)
chunks <- chunk chunks <- chunk
// reset paritioning state // reset paritioning state
chunk = chunk[:0] chunk = nil
fill = 0 fill = 0
} }
chunk = append(chunk, rls) chunk = append(chunk, rls)

Loading…
Cancel
Save