mirror of
https://github.com/Ascend/ascend-docker-runtime.git
synced 2025-10-05 21:37:06 +08:00
Match-id-1e87107c3e24b4d20298eaa1b6a44ff3faa8e550
This commit is contained in:
@@ -108,7 +108,7 @@ func process() error {
|
|||||||
return writeJson(destFilePath, writeContent)
|
return writeJson(destFilePath, writeContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createJsonString(srcFilePath, runtimeFilePath, action string) ([]byte, error) {
|
func createJSONString(srcFilePath, runtimeFilePath, action string) ([]byte, error) {
|
||||||
var writeContent []byte
|
var writeContent []byte
|
||||||
if _, err := os.Stat(srcFilePath); err == nil {
|
if _, err := os.Stat(srcFilePath); err == nil {
|
||||||
daemon, err := modifyDaemon(srcFilePath, runtimeFilePath, action)
|
daemon, err := modifyDaemon(srcFilePath, runtimeFilePath, action)
|
||||||
@@ -128,7 +128,7 @@ func createJsonString(srcFilePath, runtimeFilePath, action string) ([]byte, erro
|
|||||||
return writeContent, nil
|
return writeContent, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeJson(destFilePath string, writeContent []byte) error {
|
func writeJSON(destFilePath string, writeContent []byte) error {
|
||||||
if _, err := os.Stat(destFilePath); os.IsNotExist(err) {
|
if _, err := os.Stat(destFilePath); os.IsNotExist(err) {
|
||||||
const perm = 0600
|
const perm = 0600
|
||||||
file, err := os.OpenFile(destFilePath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, perm)
|
file, err := os.OpenFile(destFilePath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, perm)
|
||||||
@@ -145,9 +145,8 @@ func writeJson(destFilePath string, writeContent []byte) error {
|
|||||||
return fmt.Errorf("close target file failed")
|
return fmt.Errorf("close target file failed")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
} else {
|
|
||||||
return fmt.Errorf("target file already existed")
|
|
||||||
}
|
}
|
||||||
|
return fmt.Errorf("target file already existed")
|
||||||
}
|
}
|
||||||
|
|
||||||
func modifyDaemon(srcFilePath, runtimeFilePath, action string) (map[string]interface{}, error) {
|
func modifyDaemon(srcFilePath, runtimeFilePath, action string) (map[string]interface{}, error) {
|
||||||
@@ -191,7 +190,7 @@ func modifyDaemon(srcFilePath, runtimeFilePath, action string) (map[string]inter
|
|||||||
return daemon, nil
|
return daemon, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadOriginJson(srcFilePath string) (map[string]interface{}, error) {
|
func loadOrigin(srcFilePath string) (map[string]interface{}, error) {
|
||||||
if fileInfo, err := os.Stat(srcFilePath); err != nil {
|
if fileInfo, err := os.Stat(srcFilePath); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if fileInfo.Size() > maxFileSize {
|
} else if fileInfo.Size() > maxFileSize {
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
const mockDeviceId = 100
|
const mockDeviceID = 100
|
||||||
|
|
||||||
type mockWorker struct{}
|
type mockWorker struct{}
|
||||||
|
|
||||||
|
@@ -19,9 +19,8 @@ import (
|
|||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"mindxcheckutils"
|
|
||||||
|
|
||||||
"huawei.com/npu-exporter/hwlog"
|
"huawei.com/npu-exporter/hwlog"
|
||||||
|
"mindxcheckutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Reference in New Issue
Block a user