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

fix(class): Don't reconcile when harbor-class changed #1029

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pkg/event-filter/class/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (cf *Filter) Delete(e event.DeleteEvent) bool {

// Update returns true if the Update event should be processed.
func (cf *Filter) Update(e event.UpdateEvent) bool {
return cf.HarborClassAnnotationMatch(e.ObjectOld) || cf.HarborClassAnnotationMatch(e.ObjectNew)
return cf.HarborClassAnnotationMatch(e.ObjectNew)
}

// Generic returns true if the Generic event should be processed.
Expand Down
14 changes: 7 additions & 7 deletions pkg/event-filter/class/class_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ var _ = Describe("class-filter", func() {

It("Should match", func() {
ok := cf.Update(event.UpdateEvent{ObjectOld: oldResource, ObjectNew: newResource})
Expect(ok).To(BeTrue())
Expect(ok).To(BeFalse())
})
})
})
Expand Down Expand Up @@ -368,7 +368,7 @@ var _ = Describe("class-filter", func() {

It("Should match", func() {
ok := cf.Update(event.UpdateEvent{ObjectOld: oldResource, ObjectNew: newResource})
Expect(ok).To(BeTrue())
Expect(ok).To(BeFalse())
})
})
})
Expand Down Expand Up @@ -434,7 +434,7 @@ var _ = Describe("class-filter", func() {

It("Should match", func() {
ok := cf.Update(event.UpdateEvent{ObjectOld: oldResource, ObjectNew: newResource})
Expect(ok).To(BeTrue())
Expect(ok).To(BeFalse())
})
})
})
Expand Down Expand Up @@ -1079,7 +1079,7 @@ var _ = Describe("class-filter", func() {

It("Should match", func() {
ok := cf.Update(event.UpdateEvent{ObjectOld: oldResource, ObjectNew: newResource})
Expect(ok).To(BeTrue())
Expect(ok).To(BeFalse())
})
})

Expand All @@ -1092,7 +1092,7 @@ var _ = Describe("class-filter", func() {

It("Should match", func() {
ok := cf.Update(event.UpdateEvent{ObjectOld: oldResource, ObjectNew: newResource})
Expect(ok).To(BeTrue())
Expect(ok).To(BeFalse())
})
})

Expand All @@ -1105,7 +1105,7 @@ var _ = Describe("class-filter", func() {

It("Should match", func() {
ok := cf.Update(event.UpdateEvent{ObjectOld: oldResource, ObjectNew: newResource})
Expect(ok).To(BeTrue())
Expect(ok).To(BeFalse())
})
})

Expand All @@ -1118,7 +1118,7 @@ var _ = Describe("class-filter", func() {

It("Should match", func() {
ok := cf.Update(event.UpdateEvent{ObjectOld: oldResource, ObjectNew: newResource})
Expect(ok).To(BeTrue())
Expect(ok).To(BeFalse())
})
})

Expand Down
6 changes: 6 additions & 0 deletions pkg/resources/checksum/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"sync"

goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1beta1"
"github.com/goharbor/harbor-operator/pkg/factories/logger"
"github.com/goharbor/harbor-operator/pkg/version"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -64,6 +65,11 @@ func (d *Dependencies) ComputeChecksum(resource metav1.Object, onlySpec bool) st
return resource.GetResourceVersion()
}

annotations := resource.GetAnnotations()
if value, ok := annotations[goharborv1.HarborClassAnnotation]; ok {
return fmt.Sprintf("%d-%s", resource.GetGeneration(), value)
}

return fmt.Sprintf("%d", resource.GetGeneration())
}

Expand Down