Skip to content

Commit

Permalink
Do not update pod labels if they haven't changed (ray-project#1304)
Browse files Browse the repository at this point in the history
Do not update pod labels if they haven't changed
  • Loading branch information
JoshKarpel authored and blublinsky committed Aug 15, 2023
1 parent 2170b96 commit 44c0cec
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 @@ -1162,14 +1162,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 44c0cec

Please sign in to comment.