Skip to content

Commit

Permalink
fix service status update.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyjhtangtang committed Apr 16, 2024
1 parent c0e8d33 commit 5dc464b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
Binary file added cmd/yurt-manager/yurt-manager
Binary file not shown.
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

0 comments on commit 5dc464b

Please sign in to comment.