Skip to content

Commit 5a6b165

Browse files
committed
fix: creating multiple pods at the same time will be assigned to the same NPU.
1 parent caa5b03 commit 5a6b165

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

internal/server/server.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ import (
2020
"context"
2121
"flag"
2222
"fmt"
23+
"math"
2324
"net"
2425
"os"
2526
"path"
27+
"strconv"
2628
"strings"
2729
"time"
2830

@@ -350,6 +352,15 @@ func (ps *PluginServer) Allocate(ctx context.Context, reqs *v1beta1.AllocateRequ
350352
success := false
351353
var pod *v1.Pod
352354
defer func() {
355+
if success {
356+
annotations := make(map[string]string)
357+
annotations[util.DeviceBindPhase] = util.DeviceBindSuccess
358+
annotations[util.AssignedTimeAnnotations] = strconv.FormatUint(math.MaxUint64, 10)
359+
err := util.PatchPodAnnotations(pod, annotations)
360+
if err != nil {
361+
klog.Errorf("patch pod %s annotations error: %v", pod.Name, err)
362+
}
363+
}
353364
lockerr := nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend, pod, success)
354365
if lockerr != nil {
355366
klog.Errorf("failed to release lock:%s", lockerr.Error())

0 commit comments

Comments
 (0)