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

Do not update pod labels if they haven't changed #1304

Merged
merged 1 commit into from
Aug 11, 2023
Merged
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
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