Skip to content

Commit cc2ce77

Browse files
committed
chore: merge code unit test issues
1 parent 2f8eeee commit cc2ce77

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

internal/controller/tensorfusionworkload_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ func (r *TensorFusionWorkloadReconciler) scaleUpWorkers(ctx context.Context, wor
393393
return ctrl.Result{RequeueAfter: constants.PendingRequeueDuration}, nil
394394
}
395395

396-
pod, err := r.tryStartWorker(ctx, workerGenerator, gpus, workload, hash)
396+
_, err = r.tryStartWorker(ctx, workerGenerator, gpus, workload, hash)
397397
if err != nil {
398398
// Try to release all allocated GPUs if pod creation fails
399399
gpus := lo.Map(gpus, func(gpu *tfv1.GPU, _ int) types.NamespacedName {

internal/gpuallocator/gpuallocator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (s *GpuAllocator) Alloc(
138138
}
139139

140140
// Dealloc a request from gpu to release available resources on it.
141-
func (s *GpuAllocator) Dealloc(ctx context.Context, workloadNameNamespace tfv1.NameNamespace, request tfv1.Resource, gpu *tfv1.GPU) error {
141+
func (s *GpuAllocator) Dealloc(ctx context.Context, workloadNameNamespace tfv1.NameNamespace, request tfv1.Resource, gpus []types.NamespacedName) error {
142142
log := log.FromContext(ctx)
143143
s.storeMutex.Lock()
144144
defer s.storeMutex.Unlock()

internal/gpuallocator/gpuallocator_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ var _ = Describe("GPU Allocator", func() {
176176
allocatedVram := allocatedGPU.Status.Available.Vram.DeepCopy()
177177

178178
// Now deallocate
179-
err = allocator.Dealloc(ctx, workloadNameNs, request, allocatedGPU)
179+
err = allocator.Dealloc(ctx, workloadNameNs, request, []types.NamespacedName{client.ObjectKeyFromObject(gpus[0])})
180180
Expect(err).NotTo(HaveOccurred())
181181

182182
allocator.syncToK8s(ctx)
@@ -201,7 +201,7 @@ var _ = Describe("GPU Allocator", func() {
201201
}
202202

203203
// Allocate 2 GPUs
204-
allocatedGPUs, err := allocator.Alloc(ctx, "test-pool", request, 2, "")
204+
allocatedGPUs, err := allocator.Alloc(ctx, "test-pool", tfv1.NameNamespace{Namespace: "default", Name: "test-workload"}, request, 2, "")
205205
Expect(err).NotTo(HaveOccurred())
206206
Expect(allocatedGPUs).To(HaveLen(2))
207207

@@ -234,7 +234,7 @@ var _ = Describe("GPU Allocator", func() {
234234
return client.ObjectKeyFromObject(gpu)
235235
})
236236
// Now deallocate all GPUs including the non-existent one
237-
err = allocator.Dealloc(ctx, request, gpusToDeallocKeys)
237+
err = allocator.Dealloc(ctx, tfv1.NameNamespace{Namespace: "default", Name: "test-workload"}, request, gpusToDeallocKeys)
238238
Expect(err).NotTo(HaveOccurred())
239239

240240
// Verify resources were restored for existing GPUs

internal/metrics/recorder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (mr *MetricsRecorder) RecordMetrics(writer io.Writer) {
178178
enc.AddTag("worker_name", metrics.WorkerName)
179179
enc.AddTag("workload_name", metrics.WorkloadName)
180180

181-
enc.AddField("gpu_count", metricsProto.MustNewValue(metrics.GPUCount))
181+
enc.AddField("gpu_count", metricsProto.MustNewValue(int64(metrics.GPUCount)))
182182
enc.AddField("tflops_limit", metricsProto.MustNewValue(metrics.TflopsLimit))
183183
enc.AddField("tflops_request", metricsProto.MustNewValue(metrics.TflopsRequest))
184184
enc.AddField("raw_cost", metricsProto.MustNewValue(metrics.RawCost))
@@ -205,7 +205,7 @@ func (mr *MetricsRecorder) RecordMetrics(writer io.Writer) {
205205
enc.AddField("allocated_tflops_percent", metricsProto.MustNewValue(metrics.AllocatedTflopsPercent))
206206
enc.AddField("allocated_vram_bytes", metricsProto.MustNewValue(metrics.AllocatedVramBytes))
207207
enc.AddField("allocated_vram_percent", metricsProto.MustNewValue(metrics.AllocatedVramPercent))
208-
enc.AddField("gpu_count", metricsProto.MustNewValue(len(metrics.GPUModels)))
208+
enc.AddField("gpu_count", metricsProto.MustNewValue(int64(len(metrics.GPUModels))))
209209
enc.AddField("raw_cost", metricsProto.MustNewValue(metrics.RawCost))
210210
enc.EndLine(now)
211211
}

0 commit comments

Comments
 (0)