Skip to content

Commit

Permalink
Add kubernetes event to inform user of upgrade strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
chiayi committed Dec 12, 2024
1 parent 4bd2dab commit 31f171a
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("Zero Downtime Environmental Variable is set to `%s`, zero downtime upgrade is set to `%t`", strings.ToLower(zeroDowntimeEnvVar), enableZeroDowntime)
}
if rayServiceSpecUpgradeStrategy != nil {
enableZeroDowntime = *rayServiceSpecUpgradeStrategy == rayv1.NewCluster
strategyMessage = fmt.Sprintf("Upgrade Strategy is set to `%s`, zero downtime upgrade is set to `%t`", *rayServiceSpecUpgradeStrategy, enableZeroDowntime)
}

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 @@ -882,8 +882,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 31f171a

Please sign in to comment.