@@ -88,6 +88,15 @@ func (r *GPUReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
8888 return ctrl.Result {}, fmt .Errorf ("node %s is not assigned to any pool" , gpunode .Name )
8989 }
9090
91+ if gpu .Status .UsedBy == "" {
92+ patch := client .MergeFrom (gpu .DeepCopy ())
93+ gpu .Status .UsedBy = tfv1 .UsedByTensorFusion
94+ if err := r .Status ().Patch (ctx , gpu , patch ); err != nil {
95+ return ctrl.Result {}, fmt .Errorf ("patch gpu %s: %w" , gpu .Name , err )
96+ }
97+ return ctrl.Result {}, nil
98+ }
99+
91100 // No need to calculate patch since GPU's owner pool not changed
92101 if gpu .Labels != nil && gpu .Labels [constants .GpuPoolKey ] == poolName {
93102 return ctrl.Result {}, nil
@@ -98,13 +107,10 @@ func (r *GPUReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
98107 gpu .Labels = make (map [string ]string )
99108 }
100109 gpu .Labels [constants .GpuPoolKey ] = poolName
101- if gpu .Status .UsedBy == "" {
102- gpu .Status .UsedBy = tfv1 .UsedByTensorFusion
103- }
104-
105110 if err := r .Patch (ctx , gpu , patch ); err != nil {
106111 return ctrl.Result {}, fmt .Errorf ("patch gpu %s: %w" , gpu .Name , err )
107112 }
113+
108114 return ctrl.Result {}, nil
109115}
110116
0 commit comments