Skip to content

Commit

Permalink
Merge pull request #12 from Project-HAMi/fixlint
Browse files Browse the repository at this point in the history
fix golink for server.go
  • Loading branch information
archlitchi authored Dec 16, 2024
2 parents 8098075 + 43f1e99 commit 4beb38a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ascend-device-plugin-2.4.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ spec:
priorityClassName: "system-node-critical"
serviceAccountName: hami-ascend
containers:
- image: projecthami/ascend-device-plugin:main
- image: projecthami/ascend-device-plugin:v1.0.1
imagePullPolicy: IfNotPresent
name: device-plugin
resources:
Expand Down
20 changes: 16 additions & 4 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,26 @@ func (ps *PluginServer) Allocate(ctx context.Context, reqs *v1beta1.AllocateRequ
pod, err := util.GetPendingPod(ctx, ps.nodeName)
if err != nil {
klog.Errorf("get pending pod error: %v", err)
nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend)
lockerr := nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend)
if lockerr != nil {
klog.Errorf("failed to release lock:%s", err.Error())
}
return nil, fmt.Errorf("get pending pod error: %v", err)
}
resp := v1beta1.ContainerAllocateResponse{}
IDs, temps, err := ps.parsePodAnnotation(pod)
if err != nil {
nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend)
lockerr := nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend)
if lockerr != nil {
klog.Errorf("failed to release lock:%s", err.Error())
}
return nil, fmt.Errorf("parse pod annotation error: %v", err)
}
if len(IDs) == 0 {
nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend)
lockerr := nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend)
if lockerr != nil {
klog.Errorf("failed to release lock:%s", err.Error())
}
return nil, fmt.Errorf("empty id from pod annotation")
}
ascendVisibleDevices := fmt.Sprintf("%d", IDs[0])
Expand All @@ -349,7 +358,10 @@ func (ps *PluginServer) Allocate(ctx context.Context, reqs *v1beta1.AllocateRequ
resp.Envs["ASCEND_VNPU_SPECS"] = ascendVNPUSpec
}
klog.V(5).Infof("allocate response: %v", resp)
nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend)
lockerr := nodelock.ReleaseNodeLock(ps.nodeName, NodeLockAscend)
if lockerr != nil {
klog.Errorf("failed to release lock:%s", err.Error())
}
return &v1beta1.AllocateResponse{ContainerResponses: []*v1beta1.ContainerAllocateResponse{&resp}}, nil
}

Expand Down

0 comments on commit 4beb38a

Please # to comment.