@@ -332,18 +332,11 @@ func (r *RayClusterReconciler) rayClusterReconcile(ctx context.Context, request
332
332
333
333
// Calculate the new status for the RayCluster. Note that the function will deep copy `instance` instead of mutating it.
334
334
newInstance , calculateErr := r .calculateStatus (ctx , instance , reconcileErr )
335
+ var updateErr error
335
336
if calculateErr != nil {
336
337
logger .Info ("Got error when calculating new status" , "cluster name" , request .Name , "error" , calculateErr )
337
- }
338
-
339
- // Check if the status needs to be updated.
340
- var updateErr error
341
- if calculateErr == nil && r .inconsistentRayClusterStatus (ctx , originalRayClusterInstance .Status , newInstance .Status ) {
342
- logger .Info ("rayClusterReconcile" , "Update CR status" , request .Name , "status" , newInstance .Status )
343
- updateErr = r .Status ().Update (ctx , newInstance )
344
- if updateErr != nil {
345
- logger .Info ("Got error when updating status" , "cluster name" , request .Name , "error" , updateErr , "RayCluster" , newInstance )
346
- }
338
+ } else {
339
+ updateErr = r .updateRayClusterStatus (ctx , originalRayClusterInstance , newInstance )
347
340
}
348
341
349
342
// Return error based on order.
@@ -1451,24 +1444,17 @@ func (r *RayClusterReconciler) reconcileAutoscalerRoleBinding(ctx context.Contex
1451
1444
return nil
1452
1445
}
1453
1446
1454
- func (r * RayClusterReconciler ) updateClusterState (ctx context.Context , instance * rayv1. RayCluster , clusterState rayv1.ClusterState ) error {
1447
+ func (r * RayClusterReconciler ) updateRayClusterStatus (ctx context.Context , originalRayClusterInstance , newInstance * rayv1.RayCluster ) error {
1455
1448
logger := ctrl .LoggerFrom (ctx )
1456
- if instance . Status . State == clusterState {
1449
+ if ! r . inconsistentRayClusterStatus ( ctx , originalRayClusterInstance . Status , newInstance . Status ) {
1457
1450
return nil
1458
1451
}
1459
- instance .Status .State = clusterState
1460
- logger .Info ("updateClusterState" , "Update CR Status.State" , clusterState )
1461
- return r .Status ().Update (ctx , instance )
1462
- }
1463
-
1464
- func (r * RayClusterReconciler ) updateClusterReason (ctx context.Context , instance * rayv1.RayCluster , clusterReason string ) error {
1465
- logger := ctrl .LoggerFrom (ctx )
1466
- if instance .Status .Reason == clusterReason {
1467
- return nil
1452
+ logger .Info ("updateRayClusterStatus" , "name" , originalRayClusterInstance .Name , "old status" , originalRayClusterInstance .Status , "new status" , newInstance .Status )
1453
+ err := r .Status ().Update (ctx , newInstance )
1454
+ if err != nil {
1455
+ logger .Info ("Error updating status" , "name" , originalRayClusterInstance .Name , "error" , err , "RayCluster" , newInstance )
1468
1456
}
1469
- instance .Status .Reason = clusterReason
1470
- logger .Info ("updateClusterReason" , "Update CR Status.Reason" , clusterReason )
1471
- return r .Status ().Update (ctx , instance )
1457
+ return err
1472
1458
}
1473
1459
1474
1460
// sumGPUs sums the GPUs in the given resource list.
0 commit comments