Skip to content

Commit

Permalink
Check generation to ensure index working on same object
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Mar 14, 2022
1 parent a74b910 commit 32f9776
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/cache/internal/cache_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ func (c *CacheReader) List(_ context.Context, out client.ObjectList, opts ...cli
for i := range list {
obj := list[i].(client.Object)
key := client.ObjectKey{Namespace: obj.GetNamespace(), Name: obj.GetName()}
if _, exists := objmap[key]; exists {
numap[key] = obj
if o, exists := objmap[key]; exists {
if o.(client.Object).GetGeneration() == obj.GetGeneration() {
numap[key] = obj
} else {
return fmt.Errorf("multiple generation found in indices for %+v %s/%s", obj.GetObjectKind().GroupVersionKind(), obj.GetNamespace(), obj.GetName())
}
}
}
objmap = numap
Expand Down

0 comments on commit 32f9776

Please sign in to comment.