Skip to content

Commit

Permalink
Add kubernetes event to inform user of upgrade strategy (#2592)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiayi authored Dec 18, 2024
1 parent 8362483 commit c8f826b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ray-operator/controllers/ray/rayservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,20 @@ func (r *RayServiceReconciler) reconcileRayCluster(ctx context.Context, rayServi
// If no fields are set, zero downtime upgrade by default is enabled.
// Spec.UpgradeStrategy takes precedence over ENABLE_ZERO_DOWNTIME.
enableZeroDowntime := true
strategyMessage := ""
if zeroDowntimeEnvVar != "" {
enableZeroDowntime = strings.ToLower(zeroDowntimeEnvVar) != "false"
strategyMessage = fmt.Sprintf("ENABLE_ZERO_DOWNTIME environmental variable is set to %q", strings.ToLower(zeroDowntimeEnvVar))
}
if rayServiceSpecUpgradeStrategy != nil {
enableZeroDowntime = *rayServiceSpecUpgradeStrategy == rayv1.NewCluster
strategyMessage = fmt.Sprintf("Upgrade Strategy is set to %q", *rayServiceSpecUpgradeStrategy)
}

if enableZeroDowntime || !enableZeroDowntime && activeRayCluster == nil {
if enableZeroDowntime && activeRayCluster != nil {
r.Recorder.Event(rayServiceInstance, "Normal", "UpgradeStrategy", strategyMessage)
}
// Add a pending cluster name. In the next reconcile loop, shouldPrepareNewRayCluster will return DoNothing and we will
// actually create the pending RayCluster instance.
r.markRestartAndAddPendingClusterName(ctx, rayServiceInstance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,9 @@ func TestReconcileRayCluster(t *testing.T) {
}
fakeClient := clientFake.NewClientBuilder().WithScheme(newScheme).WithRuntimeObjects(runtimeObjects...).Build()
r := RayServiceReconciler{
Client: fakeClient,
Scheme: newScheme,
Client: fakeClient,
Scheme: newScheme,
Recorder: record.NewFakeRecorder(1),
}
service := rayService.DeepCopy()
if tc.rayServiceUpgradeStrategy != "" {
Expand Down

0 comments on commit c8f826b

Please sign in to comment.