Skip to content

Commit

Permalink
fix status watcher
Browse files Browse the repository at this point in the history
Signed-off-by: Thibault Mange <[email protected]>
  • Loading branch information
thibaultmg committed Jul 26, 2024
1 parent 7ad224a commit 75ccf36
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions operators/endpointmetrics/controllers/status/status_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,28 @@ func (r *StatusReconciler) requeueWithOptionalDelay(err error) (ctrl.Result, err

// SetupWithManager sets up the controller with the Manager.
func (r *StatusReconciler) SetupWithManager(mgr ctrl.Manager) error {
filterOutStandardConditions := func(c []oav1beta1.StatusCondition) []oav1beta1.StatusCondition {
var filtered []oav1beta1.StatusCondition
for _, condition := range c {
if condition.Type == "Available" || condition.Type == "Progressing" || condition.Type == "Degraded" {
continue
}
filtered = append(filtered, condition)
}
return filtered
}
pred := predicate.Funcs{
CreateFunc: func(e event.CreateEvent) bool {
return false
},
UpdateFunc: func(e event.UpdateEvent) bool {
if e.ObjectNew.GetNamespace() == r.Namespace &&
!reflect.DeepEqual(e.ObjectNew.(*oav1beta1.ObservabilityAddon).Status,
e.ObjectOld.(*oav1beta1.ObservabilityAddon).Status) {
return true
if e.ObjectNew.GetNamespace() != r.Namespace {
return false
}
return false

newConditions := filterOutStandardConditions(e.ObjectNew.(*oav1beta1.ObservabilityAddon).Status.Conditions)
oldConditions := filterOutStandardConditions(e.ObjectOld.(*oav1beta1.ObservabilityAddon).Status.Conditions)
return !reflect.DeepEqual(newConditions, oldConditions)
},
DeleteFunc: func(e event.DeleteEvent) bool {
return false
Expand Down

0 comments on commit 75ccf36

Please sign in to comment.