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

Do not modify the informer cache objects in resource.AnnotationChangedPredicate.Update #561

Merged
merged 1 commit into from
Sep 25, 2023
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
12 changes: 10 additions & 2 deletions pkg/resource/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ type AnnotationChangedPredicate struct {
ignored []string
}

func copyAnnotations(an map[string]string) map[string]string {
r := make(map[string]string, len(an))
for k, v := range an {
r[k] = v
}
return r
}

// Update implements default UpdateEvent filter for validating annotation change.
func (a AnnotationChangedPredicate) Update(e event.UpdateEvent) bool {
if e.ObjectOld == nil {
Expand All @@ -86,8 +94,8 @@ func (a AnnotationChangedPredicate) Update(e event.UpdateEvent) bool {
return false
}

na := e.ObjectNew.GetAnnotations()
oa := e.ObjectOld.GetAnnotations()
na := copyAnnotations(e.ObjectNew.GetAnnotations())
oa := copyAnnotations(e.ObjectOld.GetAnnotations())

for _, k := range a.ignored {
delete(na, k)
Expand Down
Loading