@@ -30,6 +30,11 @@ func TestCreateOrUpdateTensorFusionGPU(t *testing.T) {
3030 gpuNode := & tfv1.GPUNode {
3131 ObjectMeta : metav1.ObjectMeta {
3232 Name : gpuNodeName ,
33+ OwnerReferences : []metav1.OwnerReference {
34+ {
35+ Name : "test-gpu-pool" ,
36+ },
37+ },
3338 },
3439 }
3540
@@ -38,7 +43,8 @@ func TestCreateOrUpdateTensorFusionGPU(t *testing.T) {
3843
3944 k8sClient := fake .NewClientBuilder ().WithScheme (scheme ).WithStatusSubresource (& tfv1.GPU {}).Build ()
4045
41- gpu := createOrUpdateTensorFusionGPU (k8sClient , ctx , k8sNodeName , gpuNode , uuid , deviceName , memInfo , tflops )
46+ gpu , err := createOrUpdateTensorFusionGPU (k8sClient , ctx , k8sNodeName , gpuNode , uuid , deviceName , memInfo , tflops )
47+ assert .NoError (t , err )
4248
4349 // Assertions
4450 assert .NotNil (t , gpu , "GPU object should not be nil" )
@@ -51,10 +57,13 @@ func TestCreateOrUpdateTensorFusionGPU(t *testing.T) {
5157 gpu .Status .NodeSelector , "Node selector should match" )
5258
5359 // Verify labels and annotations
54- assert .Equal (t , map [string ]string {constants .LabelKeyOwner : gpuNodeName }, gpu .Labels , "GPU labels should match" )
60+ assert .Equal (t , map [string ]string {
61+ constants .LabelKeyOwner : gpuNodeName ,
62+ constants .GpuPoolKey : "test-gpu-pool" ,
63+ }, gpu .Labels , "GPU labels should match" )
5564 assert .Contains (t , gpu .Annotations , constants .LastSyncTimeAnnotationKey ,
5665 "GPU annotations should contain last report time" )
57- _ , err : = time .Parse (time .RFC3339 , gpu .Annotations [constants .LastSyncTimeAnnotationKey ])
66+ _ , err = time .Parse (time .RFC3339 , gpu .Annotations [constants .LastSyncTimeAnnotationKey ])
5867 assert .NoError (t , err , "Last report time annotation should be a valid RFC3339 timestamp" )
5968
6069 // Verify the Available field does not change after the update
@@ -64,7 +73,8 @@ func TestCreateOrUpdateTensorFusionGPU(t *testing.T) {
6473 assert .NoError (t , err )
6574
6675 tflops .Add (resource .MustParse ("100" ))
67- updatedGpu := createOrUpdateTensorFusionGPU (k8sClient , ctx , k8sNodeName , gpuNode , uuid , deviceName , memInfo , tflops )
76+ updatedGpu , err := createOrUpdateTensorFusionGPU (k8sClient , ctx , k8sNodeName , gpuNode , uuid , deviceName , memInfo , tflops )
77+ assert .NoError (t , err )
6878 assert .NotEqual (t , updatedGpu .Status .Capacity , gpu .Status .Capacity , "GPU capacity should not match" )
6979 assert .Equal (t , updatedGpu .Status .Available .Tflops , gpu .Status .Available .Tflops , "GPU TFlops should match" )
7080 assert .Equal (t , updatedGpu .Status .Available .Vram , gpu .Status .Available .Vram , "GPU VRAM should match" )
@@ -84,6 +94,11 @@ func TestGPUControllerReference(t *testing.T) {
8494 ObjectMeta : metav1.ObjectMeta {
8595 Name : gpuNodeName ,
8696 UID : "mock-uid" ,
97+ OwnerReferences : []metav1.OwnerReference {
98+ {
99+ Name : "test-gpu-pool" ,
100+ },
101+ },
87102 },
88103 }
89104
@@ -92,17 +107,24 @@ func TestGPUControllerReference(t *testing.T) {
92107
93108 k8sClient := fake .NewClientBuilder ().WithScheme (scheme ).WithStatusSubresource (& tfv1.GPU {}).Build ()
94109
95- gpu := createOrUpdateTensorFusionGPU (k8sClient , ctx , k8sNodeName , gpuNode , uuid , deviceName , memInfo , tflops )
110+ gpu , err := createOrUpdateTensorFusionGPU (k8sClient , ctx , k8sNodeName , gpuNode , uuid , deviceName , memInfo , tflops )
111+ assert .NoError (t , err )
96112 assert .True (t , metav1 .IsControlledBy (gpu , gpuNode ))
97113
98114 newGpuNode := & tfv1.GPUNode {
99115 ObjectMeta : metav1.ObjectMeta {
100116 Name : "new-test-gpu-node" ,
101117 UID : "new-mock-uid" ,
118+ OwnerReferences : []metav1.OwnerReference {
119+ {
120+ Name : "new-test-gpu-pool" ,
121+ },
122+ },
102123 },
103124 }
104125
105- gpu = createOrUpdateTensorFusionGPU (k8sClient , ctx , k8sNodeName , newGpuNode , uuid , deviceName , memInfo , tflops )
126+ gpu , err = createOrUpdateTensorFusionGPU (k8sClient , ctx , k8sNodeName , newGpuNode , uuid , deviceName , memInfo , tflops )
127+ assert .NoError (t , err )
106128 assert .NotNil (t , gpu .OwnerReferences [0 ].Kind )
107129 assert .NotNil (t , gpu .OwnerReferences [0 ].APIVersion )
108130 assert .True (t , metav1 .IsControlledBy (gpu , newGpuNode ))
@@ -127,6 +149,11 @@ func TestPatchGPUNodeStatus(t *testing.T) {
127149 ObjectMeta : metav1.ObjectMeta {
128150 Name : "test-gpu-node" ,
129151 Namespace : "default" ,
152+ OwnerReferences : []metav1.OwnerReference {
153+ {
154+ Name : "test-gpu-pool" ,
155+ },
156+ },
130157 },
131158 Status : tfv1.GPUNodeStatus {
132159 Phase : "" , // Empty phase should be set to pending
@@ -161,6 +188,11 @@ func TestPatchGPUNodeStatus(t *testing.T) {
161188 ObjectMeta : metav1.ObjectMeta {
162189 Name : "test-gpu-node-running" ,
163190 Namespace : "default" ,
191+ OwnerReferences : []metav1.OwnerReference {
192+ {
193+ Name : "test-gpu-pool" ,
194+ },
195+ },
164196 },
165197 Status : tfv1.GPUNodeStatus {
166198 Phase : tfv1 .TensorFusionGPUNodePhaseRunning ,
@@ -194,6 +226,11 @@ func TestPatchGPUNodeStatus(t *testing.T) {
194226 ObjectMeta : metav1.ObjectMeta {
195227 Name : "test-gpu-node-zero" ,
196228 Namespace : "default" ,
229+ OwnerReferences : []metav1.OwnerReference {
230+ {
231+ Name : "test-gpu-pool" ,
232+ },
233+ },
197234 },
198235 Status : tfv1.GPUNodeStatus {
199236 Phase : "" ,
@@ -279,6 +316,11 @@ func TestPatchGPUNodeStatus_ErrorScenarios(t *testing.T) {
279316 ObjectMeta : metav1.ObjectMeta {
280317 Name : "nonexistent-gpu-node" ,
281318 Namespace : "default" ,
319+ OwnerReferences : []metav1.OwnerReference {
320+ {
321+ Name : "test-gpu-pool" ,
322+ },
323+ },
282324 },
283325 }
284326 },
@@ -315,6 +357,11 @@ func TestPatchGPUNodeStatus_Integration(t *testing.T) {
315357 ObjectMeta : metav1.ObjectMeta {
316358 Name : "integration-test-node" ,
317359 Namespace : "default" ,
360+ OwnerReferences : []metav1.OwnerReference {
361+ {
362+ Name : "test-gpu-pool" ,
363+ },
364+ },
318365 },
319366 Status : tfv1.GPUNodeStatus {
320367 Phase : "" ,
0 commit comments