!23 310b 适配davinci_manager_docker改名,修复挂载so的bug

Merge pull request !23 from funnyfunny8/master
This commit is contained in:
Atlas_kang
2023-07-06 11:01:26 +00:00
committed by Gitee
6 changed files with 81 additions and 76 deletions

View File

@@ -7,7 +7,6 @@
/var/slogd
/usr/lib64/libsemanage.so.2
/usr/lib64/libmmpa.so
/usr/lib64/libcrypto.so.1.1
/usr/lib64/libdrvdsmi.so
/usr/lib64/libdcmi.so
/usr/lib64/libstackcore.so
@@ -19,4 +18,3 @@
/usr/lib64/libadump.so
/usr/lib64/libtsd_eventclient.so
/usr/lib64/aicpu_kernels
/usr/lib64/libyaml-0.so.2

View File

@@ -40,6 +40,21 @@ function save_install_args() {
} >> "${INSTALL_PATH}"/ascend_docker_runtime_install.info
}
function add_so() {
if grep -qi "ubuntu" "/etc/os-release"; then
echo "[info]: os is Ubuntu"
echo -e "\n/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo "/usr/lib/aarch64-linux-gnu/libyaml-0.so.2" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
elif grep -qi "euler" "/etc/os-release"; then
echo "[info]: os is Euler/OpenEuler"
echo -e "\n/usr/lib64/libcrypto.so.1.1" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo "/usr/lib64/libyaml-0.so.2" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
else
echo "ERROR: not support this os"
exit
fi
}
function install()
{
echo 'installing ascend docker runtime'
@@ -89,20 +104,10 @@ function install()
cp -f ./base.list_A200ISoC ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
elif [ "${a500a2}" == "y" ]; then
cp -f ./base.list_A500A2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
add_so
elif [ "${a200ia2}" == "y" ]; then
cp -f ./base.list_A200IA2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
if grep -qi "ubuntu" "/etc/os-release"; then
echo "[info]: A200IA2 os is Ubuntu"
echo -e "\n/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo "/usr/lib/aarch64-linux-gnu/libyaml-0.so.2.0.6" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
elif grep -qi "euler" "/etc/os-release"; then
echo "[info]: A200IA2 os is Euler/OpenEuler"
echo -e "\n/usr/lib64/libcrypto.so.1.1.1m" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo "/usr/lib64/libyaml-0.so.2.0.9" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
else
echo "ERROR: not support this os"
exit
fi
add_so
else
cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
fi
@@ -185,6 +190,7 @@ function upgrade()
elif [ "$(grep "a500a2=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "a500a2=y" ]; then
a500a2=y
cp -f ./base.list_A500A2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
add_so
elif [ "$(grep "a200=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "a200=y" ]; then
a200=y
cp -f ./base.list_A200 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
@@ -194,18 +200,7 @@ function upgrade()
elif [ "x$(grep "a200ia2=y" "${INSTALL_PATH}"/ascend_docker_runtime_install.info)" == "xa200ia2=y" ]; then
a200ia2=y
cp -f ./base.list_A200IA2 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
if grep -qi "ubuntu" "/etc/os-release"; then
echo "[info]: A200IA2 os is Ubuntu"
echo -e "\n/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo -e "/usr/lib/aarch64-linux-gnu/libyaml-0.so.2.0.6" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
elif grep -qi "euler" "/etc/os-release"; then
echo "[info]: A200IA2 os is Euler/OpenEuler"
echo -e "\n/usr/lib64/libcrypto.so.1.1.1m" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
echo -e "/usr/lib64/libyaml-0.so.2.0.9" >> ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
else
echo "ERROR: not support this os"
exit
fi
add_so
else
cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
fi

View File

@@ -194,9 +194,8 @@ static bool CheckWhiteList(const char* fileName)
{"/usr/lib64/libmpi_dvpp_adapter.so"}, {"/usr/lib64/libaicpu_scheduler.so"},
{"/usr/lib64/libaicpu_processer.so"}, {"/usr/lib64/libaicpu_prof.so"}, {"/usr/lib64/libaicpu_sharder.so"},
{"/usr/lib64/libadump.so"}, {"/usr/lib64/libtsd_eventclient.so"},
{"/usr/lib64/aicpu_kernels"}, {"/usr/lib64/libyaml-0.so.2"}, {"/usr/lib64/libcrypto.so.1.1.1m"},
{"/usr/lib64/libyaml-0.so.2.0.9"}, {"/usr/lib/aarch64-linux-gnu/libyaml-0.so.2.0.6"},
{"/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1"}
{"/usr/lib64/aicpu_kernels"}, {"/usr/lib64/libyaml-0.so.2"},
{"/usr/lib/aarch64-linux-gnu/libyaml-0.so.2"}, {"/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1"}
};
for (size_t iLoop = 0; iLoop < WHITE_LIST_NUM; iLoop++) {

View File

@@ -415,8 +415,8 @@ func main() {
log.Fatal("command error")
}
if err := doPrestartHook(); err != nil {
hwlog.RunLog.Errorf("ascend docker hook failed")
hwlog.OpLog.Errorf("%v ascend docker hook failed", logPrefixWords)
log.Fatal(fmt.Errorf("failed in runtime.doProcess "))
hwlog.RunLog.Errorf("ascend docker hook failed: %#v", err)
hwlog.OpLog.Errorf("%v ascend docker hook failed: %#v", logPrefixWords, err)
log.Fatal(fmt.Errorf("failed in runtime.doProcess: %#v", err))
}
}

View File

@@ -83,7 +83,10 @@ const (
devicePath = "/dev/"
davinciName = "davinci"
virtualDavinciName = "vdavinci"
davinciManager = "davinci_manager"
davinciManagerDocker = "davinci_manager_docker"
notRenameDeviceType = ""
devmmSvm = "devmm_svm"
hisiHdc = "hisi_hdc"
svm0 = "svm0"
@@ -346,20 +349,23 @@ func getValueByKey(data []string, name string) string {
return ""
}
func addDeviceToSpec(spec *specs.Spec, dPath string, vdevice bool) error {
func addDeviceToSpec(spec *specs.Spec, dPath string, deviceType string) error {
device, err := oci.DeviceFromPath(dPath)
if err != nil {
return fmt.Errorf("failed to get %s info : %#v", dPath, err)
}
if vdevice {
re := regexp.MustCompile("[0-9]+")
vDeviceNumber := re.FindAllString(dPath, -1)
switch deviceType {
case virtualDavinciName:
vDeviceNumber := regexp.MustCompile("[0-9]+").FindAllString(dPath, -1)
if len(vDeviceNumber) != 1 {
return fmt.Errorf("error vdevice : %s", dPath)
return fmt.Errorf("invalid vdavinci path: %s", dPath)
}
vPath := devicePath + davinciName + vDeviceNumber[0]
device.Path = vPath
device.Path = devicePath + davinciName + vDeviceNumber[0]
case davinciManagerDocker:
device.Path = devicePath + davinciManager
default:
// do nothing
}
spec.Linux.Devices = append(spec.Linux.Devices, *device)
@@ -390,12 +396,20 @@ func addAscend310BManagerDevice(spec *specs.Spec) error {
for _, device := range Ascend310BManageDevices {
dPath := devicePath + device
if err := addDeviceToSpec(spec, dPath, false); err != nil {
if err := addDeviceToSpec(spec, dPath, notRenameDeviceType); err != nil {
hwlog.RunLog.Warnf("failed to add %s to spec : %#v", dPath, err)
}
}
return nil
davinciManagerPath := devicePath + davinciManagerDocker
if _, err := os.Stat(davinciManagerPath); err != nil {
hwlog.RunLog.Warnf("failed to get davinci manager docker, err: %#v", err)
davinciManagerPath = devicePath + davinciManager
if _, err := os.Stat(davinciManagerPath); err != nil {
return fmt.Errorf("failed to get davinci manager, err: %#v", err)
}
}
return addDeviceToSpec(spec, davinciManagerPath, davinciManagerDocker)
}
func addCommonManagerDevice(spec *specs.Spec) error {
@@ -406,7 +420,7 @@ func addCommonManagerDevice(spec *specs.Spec) error {
for _, device := range commonManagerDevices {
dPath := devicePath + device
if err := addDeviceToSpec(spec, dPath, false); err != nil {
if err := addDeviceToSpec(spec, dPath, notRenameDeviceType); err != nil {
return fmt.Errorf("failed to add common manage device to spec : %#v", err)
}
}
@@ -415,11 +429,6 @@ func addCommonManagerDevice(spec *specs.Spec) error {
}
func addManagerDevice(spec *specs.Spec) error {
managerPath := devicePath + davinciManager
if err := addDeviceToSpec(spec, managerPath, false); err != nil {
return fmt.Errorf("add davinci_manager to spec error: %#v", err)
}
chipName, err := dcmi.GetChipName()
if err != nil {
return fmt.Errorf("get chip name error: %#v", err)
@@ -427,10 +436,11 @@ func addManagerDevice(spec *specs.Spec) error {
devType := GetDeviceTypeByChipName(chipName)
hwlog.RunLog.Infof("device type is: %s", devType)
if devType == Ascend310B {
if err = addAscend310BManagerDevice(spec); err != nil {
return fmt.Errorf("add 310B manage device error: %#v", err)
return addAscend310BManagerDevice(spec)
}
return nil
if err := addDeviceToSpec(spec, devicePath+davinciManager, notRenameDeviceType); err != nil {
return fmt.Errorf("add davinci_manager to spec error: %#v", err)
}
productType, err := dcmi.GetProductType(&dcmi.NpuWorker{})
@@ -462,16 +472,14 @@ func addDevice(spec *specs.Spec) error {
return fmt.Errorf("failed to parse device : %#v", err)
}
hwlog.RunLog.Infof("devices is: %#v", devices)
devciename := davinciName
vdevice := false
deviceName := davinciName
virtual := getValueByKey(spec.Process.Env, ascendRuntimeOptions)
if strings.Contains(virtual, "VIRTUAL") {
devciename = "v" + devciename
vdevice = true
deviceName = virtualDavinciName
}
for _, deviceId := range devices {
dPath := devicePath + devciename + strconv.Itoa(deviceId)
if err = addDeviceToSpec(spec, dPath, vdevice); err != nil {
dPath := devicePath + deviceName + strconv.Itoa(deviceId)
if err = addDeviceToSpec(spec, dPath, deviceName); err != nil {
return fmt.Errorf("failed to add davinci device to spec: %v", err)
}
}

View File

@@ -397,17 +397,22 @@ func TestAddDeviceToSpec0(t *testing.T) {
},
}
err := addDeviceToSpec(&spec, devPath, false)
err := addDeviceToSpec(&spec, devPath, notRenameDeviceType)
assert.Nil(t, err)
assert.Contains(t, spec.Linux.Devices[0].Path, devPath)
}
func TestAddAscend310BManagerDevice(t *testing.T) {
statStub := gomonkey.ApplyFunc(addDeviceToSpec, func(spec *specs.Spec, dPath string, vdevice bool) error {
statStub := gomonkey.ApplyFunc(addDeviceToSpec, func(spec *specs.Spec, dPath string, deviceType string) error {
return nil
})
defer statStub.Reset()
pathStub := gomonkey.ApplyFunc(os.Stat, func(name string) (os.FileInfo, error) {
return nil, nil
})
defer pathStub.Reset()
spec := specs.Spec{
Linux: &specs.Linux{
Devices: []specs.LinuxDevice{},
@@ -422,7 +427,7 @@ func TestAddAscend310BManagerDevice(t *testing.T) {
}
func TestAddCommonManagerDevice(t *testing.T) {
statStub := gomonkey.ApplyFunc(addDeviceToSpec, func(spec *specs.Spec, dPath string, vdevice bool) error {
statStub := gomonkey.ApplyFunc(addDeviceToSpec, func(spec *specs.Spec, dPath string, deviceType string) error {
return nil
})
defer statStub.Reset()