diff --git a/build/scripts/help.info b/build/scripts/help.info index 31fe6e0e2974de14c2578af68cfd1d0dc4636655..97e5e23e6efda2c75bda9dca92d15c6bf0c668a4 100644 --- a/build/scripts/help.info +++ b/build/scripts/help.info @@ -2,4 +2,5 @@ --install-path Specify the installation path (default: /usr/local/Ascend/Ascend-Docker-Runtime) --uninstall Uninstall the installed ascend-docker-runtime tool --upgrade Upgrade the installed ascend-docker-runtime tool - --install-type= Only A500, A200ISoC and A200 need to specify the installation type of Ascend-docker-runtime (eg: --install-type=A500) \ No newline at end of file + --install-type= Only A500, A200ISoC and A200 need to specify the installation type of Ascend-docker-runtime (eg: --install-type=A500) + --ce= Only iSula need to specify the container engine(eg: --ce=isula) \ No newline at end of file diff --git a/build/scripts/run_main.sh b/build/scripts/run_main.sh index 87d60a09108c4bedfb1ccf3d56b03eb86919cd2e..d863f0b3774b221e8c0beaa9f37f3609fa30476c 100644 --- a/build/scripts/run_main.sh +++ b/build/scripts/run_main.sh @@ -122,7 +122,7 @@ function uninstall() exit 0 fi - ${INSTALL_PATH}/script/uninstall.sh + ${INSTALL_PATH}/script/uninstall.sh ${ISULA} echo 'remove daemon.json setting success' [ -n "${INSTALL_PATH}" ] && rm -rf ${INSTALL_PATH} @@ -190,6 +190,7 @@ a500=n a200=n a200isoc=n quiet_flag=n +ISULA=n while true do @@ -235,6 +236,21 @@ do UPGRADE_FLAG=y shift ;; + --ce=*) + if [ "${ISULA}" == "y" ]; then + echo "warning: Repeat parameter!" + exit 1 + fi + + if [ "$3" == "--ce=isula" ]; then + DOCKER_CONFIG_DIR="/etc/isulad" + ISULA=y + else + echo "ERROR :Please check the parameter of --ce=" + exit 1 + fi + shift + ;; --install-type=*) if [ "${a500}" == "y" ] || [ "${a200}" == "y" ] || [ "${a200isoc}" == "y" ]; then echo "warning :Repeat parameter!" diff --git a/build/scripts/uninstall.sh b/build/scripts/uninstall.sh index 6ba1d4623a95522797dc315655dd85eb0d39a24a..2aa506ded883a9b22aeafa3e1d74629e571a4657 100644 --- a/build/scripts/uninstall.sh +++ b/build/scripts/uninstall.sh @@ -20,7 +20,14 @@ LOG_FILE="/var/log/ascend-docker-runtime/installer.log" echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "start uninstall" echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "start uninstall" >>${LOG_FILE} ROOT=$(cd $(dirname $0); pwd)/.. -DST='/etc/docker/daemon.json' +if [ "$*" == "y" ] ; then + DST='/etc/isulad/daemon.json' + echo "[INFO]: You will recover iSula's daemon" +else + DST='/etc/docker/daemon.json' + echo "[INFO]: You will recover Docker's daemon" +fi + SRC="${DST}.${PPID}" ASCEND_RUNTIME_CONFIG_DIR=/etc/ascend-docker-runtime.d diff --git a/runtime/main.go b/runtime/main.go index df1f5f973a1037ccf79062a62296c78d6aba6697..bf1d61284e65bc42651f9df61391e5408b6ce8be 100644 --- a/runtime/main.go +++ b/runtime/main.go @@ -46,6 +46,10 @@ const ( dockerRuncFile = "docker-runc" runcFile = "runc" envLength = 2 + + // ENV for device-plugin to identify ascend-docker-runtime + useAscendDocker = "ASCEND_DOCKER_RUNTIME=True" + devicePlugin = "ascend-device-plugin" ) var ( @@ -134,6 +138,21 @@ var execRunc = func() error { return nil } +func addEnvToDevicePlugin(spec *specs.Spec) { + if spec.Process.Env == nil { + return + } + + for _, line := range spec.Process.Env { + words := strings.Split(line, "=") + if len(words) == envLength && strings.TrimSpace(words[0]) == "HOSTNAME" && + strings.Contains(words[1], devicePlugin) { + spec.Process.Env = append(spec.Process.Env, useAscendDocker) + break + } + } +} + func addHook(spec *specs.Spec) error { currentExecPath, err := os.Executable() if err != nil { @@ -249,6 +268,13 @@ func modifySpecFile(path string) error { return fmt.Errorf("failed to read oci spec file %s: %v", path, err) } + if err = jsonFile.Truncate(0); err != nil { + return fmt.Errorf("failed to truncate: %v", err) + } + if _, err = jsonFile.Seek(0, 0); err != nil { + return fmt.Errorf("failed to seek: %v", err) + } + var spec specs.Spec if err = json.Unmarshal(jsonContent, &spec); err != nil { return fmt.Errorf("failed to unmarshal oci spec file %s: %v", path, err) @@ -258,6 +284,8 @@ func modifySpecFile(path string) error { return fmt.Errorf("failed to inject hook: %v", err) } + addEnvToDevicePlugin(&spec) + jsonOutput, err := json.Marshal(spec) if err != nil { return fmt.Errorf("failed to marshal OCI spec file: %v", err)