Skip to content

Commit

Permalink
check if labels have changed before updating pod
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshKarpel committed Aug 8, 2023
1 parent 7386427 commit 74a4485
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ray-operator/controllers/ray/rayservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,14 +1158,24 @@ func (r *RayServiceReconciler) labelHealthyServePods(ctx context.Context, rayClu
if pod.Labels == nil {
pod.Labels = make(map[string]string)
}

// Make a copy of the labels for comparison later, to decide whether we need to push an update.
originalLabels := make(map[string]string, len(pod.Labels))
for key, value := range pod.Labels {
originalLabels[key] = value
}

if httpProxyClient.CheckHealth() == nil {
pod.Labels[common.RayClusterServingServiceLabelKey] = common.EnableRayClusterServingServiceTrue
} else {
pod.Labels[common.RayClusterServingServiceLabelKey] = common.EnableRayClusterServingServiceFalse
}
if updateErr := r.Update(ctx, &pod); updateErr != nil {
r.Log.Error(updateErr, "Pod label Update error!", "Pod.Error", updateErr)
return updateErr

if !reflect.DeepEqual(originalLabels, pod.Labels) {
if updateErr := r.Update(ctx, &pod); updateErr != nil {
r.Log.Error(updateErr, "Pod label Update error!", "Pod.Error", updateErr)
return updateErr
}
}
}

Expand Down

0 comments on commit 74a4485

Please sign in to comment.