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 service status update. #2024

Merged
merged 1 commit into from
Apr 17, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -503,5 +503,5 @@ func (r *ReconcileLoadBalancerSet) compareAndUpdateService(svc *corev1.Service,
return nil
}

return r.Update(context.Background(), svc)
return r.Status().Update(context.Background(), svc)
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func isServiceChange(oldSvc, newSvc *v1.Service) bool {
return true
}

if isStatusChange(oldSvc, newSvc) {
return true
}

return false
}

Expand All @@ -142,6 +146,10 @@ func isAggregateAnnotationsChange(oldSvc, newSvc *v1.Service) bool {
return !reflect.DeepEqual(oldAggregateAnnotations, newAggregateAnnotations)
}

func isStatusChange(oldSvc, newSvc *v1.Service) bool {
return !reflect.DeepEqual(oldSvc.Status, newSvc.Status)
}

func NewPoolServicePredicated() predicate.Predicate {
return predicate.Funcs{
CreateFunc: func(createEvent event.CreateEvent) bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ func TestServicePredicate(t *testing.T) {
got := f.Update(event.UpdateEvent{ObjectOld: svc1, ObjectNew: svc2})
assertBool(t, true, got)
})

t.Run("modify service status", func(t *testing.T) {
svc1 := newService(v1.NamespaceDefault, mockServiceName)
svc2 := newService(v1.NamespaceDefault, mockServiceName)
svc2.Status.LoadBalancer.Ingress = []v1.LoadBalancerIngress{{IP: "1.2.3.4"}}

got := f.Update(event.UpdateEvent{ObjectOld: svc1, ObjectNew: svc2})
assertBool(t, true, got)
})
}

func assertBool(t testing.TB, expected, got bool) {
Expand Down
Loading