Skip to content

Commit 2ddcfd7

Browse files
committed
simplify status setter
1 parent 499b8d9 commit 2ddcfd7

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

internal/controller/status/status_setters.go

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -410,33 +410,8 @@ func newInferencePoolStatusSetter(status inference.InferencePoolStatus) Setter {
410410
return func(obj client.Object) (wasSet bool) {
411411
ip := helpers.MustCastObject[*inference.InferencePool](obj)
412412

413-
parentStatuses := make([]inference.ParentStatus, 0, len(ip.Status.Parents)+len(status.Parents))
414-
copy(parentStatuses, ip.Status.Parents)
415-
416-
// Helper function to find the index of a ParentRef in the list
417-
findParentIndex := func(parents []inference.ParentStatus, ref inference.ParentReference) int {
418-
for i, parent := range parents {
419-
if parent.ParentRef.Name == ref.Name &&
420-
parent.ParentRef.Namespace == ref.Namespace {
421-
return i
422-
}
423-
}
424-
return -1
425-
}
426-
427-
// Iterate over the new ParentRefs and update their conditions
428-
// or append them as new parentRefs
429-
for _, newParent := range status.Parents {
430-
index := findParentIndex(parentStatuses, newParent.ParentRef)
431-
if index != -1 {
432-
parentStatuses[index].Conditions = newParent.Conditions
433-
} else {
434-
parentStatuses = append(parentStatuses, newParent)
435-
}
436-
}
437-
438-
status.Parents = parentStatuses
439-
413+
// we build all the parent statuses at once so we can directly
414+
// compare the previous and current statuses
440415
if inferencePoolStatusEqual(ip.Status.Parents, status.Parents) {
441416
return false
442417
}

0 commit comments

Comments
 (0)