Skip to content

Commit afcb2d1

Browse files
author
limengxuan
authored
Merge pull request #11 from lengrongfu/main
update ascend uuid define logic
2 parents 588959c + ad1661e commit afcb2d1

3 files changed

Lines changed: 69 additions & 1 deletion

File tree

.github/workflows/dev.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: CI
5+
6+
on:
7+
pull_request:
8+
branches: [ "main" ]
9+
10+
env:
11+
GO_VERSION: "1.22.5"
12+
13+
jobs:
14+
golangci:
15+
name: lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: ${{ env.GO_VERSION }}
22+
- name: golangci-lint
23+
uses: golangci/golangci-lint-action@v6
24+
with:
25+
version: v1.60
26+
27+
build:
28+
env:
29+
IMAGE_NAME: ${{ secrets.IMAGE_NAME || 'projecthami/ascend-device-plugin' }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Get branch names.
35+
id: branch-names
36+
uses: tj-actions/branch-names@v8
37+
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v3
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
43+
44+
- name: Docker Login
45+
uses: docker/login-action@v3.1.0
46+
with:
47+
username: ${{ secrets.DOCKERHUB_TOKEN }}
48+
password: ${{ secrets.DOCKERHUB_PASSWD }}
49+
50+
- name: Build and push
51+
uses: docker/build-push-action@v6
52+
with:
53+
platforms: linux/amd64,linux/arm64
54+
push: true
55+
build-args: |
56+
BASE_IMAGE=ubuntu:20.04
57+
GO_VERSION=${{ env.GO_VERSION }}
58+
VERSION=${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }}-${{ github.sha }}
59+
tags: ${{ env.IMAGE_NAME }}:dev

internal/manager/manager.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/Project-HAMi/ascend-device-plugin/internal"
2424
"huawei.com/npu-exporter/v6/devmanager"
25+
"huawei.com/npu-exporter/v6/devmanager/dcmi"
2526
"k8s.io/klog/v2"
2627
)
2728

@@ -118,13 +119,18 @@ func (am *AscendManager) UpdateDevice() error {
118119
klog.Errorf("failed to get card id from device id: %v", err)
119120
return err
120121
}
122+
uuid, err := am.mgr.GetDieID(ID, dcmi.VDIE)
123+
if err != nil {
124+
klog.Errorf("failed to get uuid from device id: %v", err)
125+
return err
126+
}
121127
health, err := am.mgr.GetDeviceHealth(ID)
122128
if err != nil {
123129
klog.Errorf("failed to get device health: %v", err)
124130
return err
125131
}
126132
am.devs = append(am.devs, &Device{
127-
UUID: fmt.Sprintf("%s-%d", am.config.CommonWord, phyID),
133+
UUID: uuid,
128134
LogicID: ID,
129135
PhyID: phyID,
130136
CardID: cardID,

internal/server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ func (ps *PluginServer) parsePodAnnotation(pod *v1.Pod) ([]int32, []string, erro
260260
var IDs []int32
261261
var temps []string
262262
for _, info := range rtInfo {
263+
if info.UUID == "" {
264+
continue
265+
}
263266
d := ps.mgr.GetDeviceByUUID(info.UUID)
264267
if d == nil {
265268
return nil, nil, fmt.Errorf("unknown uuid: %s", info.UUID)

0 commit comments

Comments
 (0)