Skip to content

Commit

Permalink
update ascend uuid define logic
Browse files Browse the repository at this point in the history
Signed-off-by: rongfu.leng <lenronfu@gmail.com>
  • Loading branch information
lengrongfu committed Dec 6, 2024
1 parent 91ad27f commit 2e1bd72
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: CI

on:
pull_request:
branches: [ "main" ]

env:
GO_VERSION: "1.22.5"

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60

build:
env:
IMAGE_NAME: ${{ secrets.IMAGE_NAME || 'projecthami/ascend-device-plugin' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get branch names.
id: branch-names
uses: tj-actions/branch-names@v8

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker Login
uses: docker/#-action@v3.1.0
with:
username: ${{ secrets.DOCKERHUB_TOKEN }}
password: ${{ secrets.DOCKERHUB_PASSWD }}

- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
BASE_IMAGE=ubuntu:20.04
GO_VERSION=${{ env.GO_VERSION }}
VERSION=${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }}-${{ github.sha }}
tags: ${{ env.IMAGE_NAME }}:dev
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lint: tidy
golangci-lint run

ascend-device-plugin: tidy
$(GO) build $(BUILDARGS) -o ./ascend-device-plugin
$(GO) build $(BUILDARGS) -o ./ascend-device-plugin ./cmd

clean:
rm -rf ./ascend-device-plugin
Expand Down
8 changes: 7 additions & 1 deletion internal/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/Project-HAMi/ascend-device-plugin/internal"
"huawei.com/npu-exporter/v6/devmanager"
"huawei.com/npu-exporter/v6/devmanager/dcmi"
"k8s.io/klog/v2"
)

Expand Down Expand Up @@ -118,13 +119,18 @@ func (am *AscendManager) UpdateDevice() error {
klog.Errorf("failed to get card id from device id: %v", err)
return err
}
uuid, err := am.mgr.GetDieID(ID, dcmi.VDIE)
if err != nil {
klog.Errorf("failed to get uuid from device id: %v", err)
return err
}
health, err := am.mgr.GetDeviceHealth(ID)
if err != nil {
klog.Errorf("failed to get device health: %v", err)
return err
}
am.devs = append(am.devs, &Device{
UUID: fmt.Sprintf("%s-%d", am.config.CommonWord, phyID),
UUID: uuid,
LogicID: ID,
PhyID: phyID,
CardID: cardID,
Expand Down
3 changes: 3 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ func (ps *PluginServer) parsePodAnnotation(pod *v1.Pod) ([]int32, []string, erro
var IDs []int32
var temps []string
for _, info := range rtInfo {
if info.UUID == "" {
continue
}
d := ps.mgr.GetDeviceByUUID(info.UUID)
if d == nil {
return nil, nil, fmt.Errorf("unknown uuid: %s", info.UUID)
Expand Down

0 comments on commit 2e1bd72

Please # to comment.