Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

name: CI

on:
pull_request:
branches: [ "main" ]
on: [push, pull_request]

env:
GO_VERSION: "1.22.5"
GO_VERSION: "1.24.6"

jobs:
golangci:
Expand All @@ -19,10 +17,11 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod tidy
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
version: latest

build:
env:
Expand Down
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os"
"syscall"

"github.com/Project-HAMi/HAMi/pkg/util/client"
"github.com/Project-HAMi/ascend-device-plugin/internal"
"github.com/Project-HAMi/ascend-device-plugin/internal/manager"
"github.com/Project-HAMi/ascend-device-plugin/internal/server"
Expand Down Expand Up @@ -136,6 +137,7 @@ func main() {
if err != nil {
klog.Fatalf("init PluginServer failed, error is %v", err)
}
client.InitGlobalClient()

err = start(server)
if err != nil {
Expand Down
20 changes: 20 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,23 @@ vnpus:
memory: 12288
aiCore: 4
aiCPU: 4
- chipName: 910ProB
commonWord: Ascend910ProB
resourceName: huawei.com/Ascend910ProB
resourceMemoryName: huawei.com/Ascend910ProB-memory
memoryAllocatable: 32768
memoryCapacity: 32768
aiCore: 30
templates:
- name: vir02
memory: 2184
aiCore: 2
- name: vir04
memory: 4369
aiCore: 4
- name: vir08
memory: 8738
aiCore: 8
- name: vir16
memory: 17476
aiCore: 16
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Project-HAMi/ascend-device-plugin

go 1.22.2
go 1.24.6

require (
github.com/Project-HAMi/HAMi v0.0.0
Expand Down Expand Up @@ -57,6 +57,6 @@ require (
)

replace (
github.com/Project-HAMi/HAMi v0.0.0 => github.com/Project-HAMi/HAMi v0.0.0-20250107033239-d04fc8baaad6
github.com/Project-HAMi/HAMi v0.0.0 => github.com/Project-HAMi/HAMi v0.0.0-20250901013025-61c6cbe7d480
huawei.com/npu-exporter/v6 => gitee.com/ascend/ascend-npu-exporter/v6 v6.0.0-RC3
)
30 changes: 25 additions & 5 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
"net"
"os"
"path"
"strings"
"time"

"github.com/Project-HAMi/HAMi/pkg/device"
"github.com/Project-HAMi/HAMi/pkg/device/ascend"
"github.com/Project-HAMi/HAMi/pkg/util"
"github.com/Project-HAMi/HAMi/pkg/util/nodelock"
Expand All @@ -40,7 +42,8 @@
const (
// RegisterAnnos = "hami.io/node-register-ascend"
// PodAllocAnno = "huawei.com/AscendDevices"
NodeLockAscend = "hami.io/mutex.lock"
NodeLockAscend = "hami.io/mutex.lock"
Ascend910Prefix = "Ascend910"
)

var (
Expand Down Expand Up @@ -100,9 +103,9 @@
func (ps *PluginServer) dial(unixSocketPath string, timeout time.Duration) (*grpc.ClientConn, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
c, err := grpc.DialContext(ctx, unixSocketPath,

Check failure on line 106 in internal/server/server.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: grpc.DialContext is deprecated: use NewClient instead. Will be supported throughout 1.x. (staticcheck)

Check failure on line 106 in internal/server/server.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: grpc.DialContext is deprecated: use NewClient instead. Will be supported throughout 1.x. (staticcheck)
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),

Check failure on line 108 in internal/server/server.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: grpc.WithBlock is deprecated: this DialOption is not supported by NewClient. Will be supported throughout 1.x. (staticcheck)

Check failure on line 108 in internal/server/server.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: grpc.WithBlock is deprecated: this DialOption is not supported by NewClient. Will be supported throughout 1.x. (staticcheck)
grpc.WithContextDialer(func(ctx2 context.Context, addr string) (net.Conn, error) {
var d net.Dialer
return d.DialContext(ctx2, "unix", addr)
Expand Down Expand Up @@ -188,12 +191,19 @@
return nil
}

func (ps *PluginServer) getDeviceNetworkID(idx int) (int, error) {
if idx > 3 {
return 1, nil
}
return 0, nil
}

func (ps *PluginServer) registerHAMi() error {
devs := ps.mgr.GetDevices()
apiDevices := make([]*util.DeviceInfo, 0, len(devs))
apiDevices := make([]*device.DeviceInfo, 0, len(devs))
// hami currently believes that the index starts from 0 and is continuous.
for i, dev := range devs {
apiDevices = append(apiDevices, &util.DeviceInfo{
device := &device.DeviceInfo{
Index: uint(i),
ID: dev.UUID,
Count: int32(ps.mgr.VDeviceCount()),
Expand All @@ -202,10 +212,20 @@
Type: ps.mgr.CommonWord(),
Numa: 0,
Health: dev.Health,
})
}
if strings.HasPrefix(device.Type, Ascend910Prefix) {
NetworkID, err := ps.getDeviceNetworkID(i)
if err != nil {
return fmt.Errorf("get networkID error: %v", err)
}
device.CustomInfo = map[string]any{
"NetworkID": NetworkID,
}
}
apiDevices = append(apiDevices, device)
}
annos := make(map[string]string)
annos[ps.registerAnno] = util.MarshalNodeDevices(apiDevices)
annos[ps.registerAnno] = device.MarshalNodeDevices(apiDevices)
annos[ps.handshakeAnno] = "Reported_" + time.Now().Add(time.Duration(*reportTimeOffset)*time.Second).Format("2006.01.02 15:04:05")
node, err := util.GetNode(ps.nodeName)
if err != nil {
Expand Down
Loading