Skip to content

Commit 7626b2d

Browse files
committed
fix: strings.CutPrefix pool label
1 parent 553b223 commit 7626b2d

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

internal/controller/gpupool_controller.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,10 @@ func (r *GPUPoolReconciler) SetupWithManager(mgr ctrl.Manager) error {
284284

285285
node := obj.(*tfv1.GPUNode)
286286
for labelKey := range node.Labels {
287-
if strings.HasPrefix(labelKey, constants.GPUNodePoolIdentifierLabelPrefix) {
288-
tmp := strings.Split(labelKey, "/")
289-
if len(tmp) != 3 {
290-
continue
291-
}
287+
poolName, ok := strings.CutPrefix(labelKey, constants.GPUNodePoolIdentifierLabelPrefix)
288+
if ok {
292289
requests = append(requests, reconcile.Request{
293-
NamespacedName: types.NamespacedName{Name: tmp[2]},
290+
NamespacedName: types.NamespacedName{Name: poolName},
294291
})
295292
}
296293
}

internal/controller/gpupool_controller_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ var _ = Describe("GPUPool Controller", func() {
7171
Name: nodeNamespacedName.Name,
7272
Labels: map[string]string{
7373
fmt.Sprintf(constants.GPUNodePoolIdentifierLabelFormat, resourceName): "true",
74-
"mock-label": "true",
7574
},
7675
},
7776
Spec: tfv1.GPUNodeSpec{

0 commit comments

Comments
 (0)