From 3148e86f848144460ec406fe5a5d3b7d43c5496e Mon Sep 17 00:00:00 2001 From: weizhichen Date: Thu, 17 Aug 2023 09:18:54 +0000 Subject: [PATCH] fix --- Makefile | 4 +- pkg/blobfuse-proxy/init.sh | 157 +++++++++++++++++++------------------ pkg/blobplugin/Dockerfile | 4 +- 3 files changed, 85 insertions(+), 80 deletions(-) diff --git a/Makefile b/Makefile index 2be3cd3f09..5e061b2dd5 100644 --- a/Makefile +++ b/Makefile @@ -111,7 +111,7 @@ blob: blobfuse-proxy blob-windows: CGO_ENABLED=0 GOOS=windows go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/blobplugin.exe ./pkg/blobplugin -.PHONT: blob-darwin +.PHONY: blob-darwin blob-darwin: CGO_ENABLED=0 GOOS=darwin go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/blobplugin ./pkg/blobplugin @@ -182,4 +182,4 @@ delete-metrics-svc: .PHONY: blobfuse-proxy blobfuse-proxy: - CGO_ENABLED=0 GOOS=linux go build -mod vendor -ldflags="-s -w" -o _output/${ARCH}/blobfuse-proxy ./pkg/blobfuse-proxy + CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -mod vendor -ldflags="-s -w" -o _output/${ARCH}/blobfuse-proxy ./pkg/blobfuse-proxy diff --git a/pkg/blobfuse-proxy/init.sh b/pkg/blobfuse-proxy/init.sh index 40643f51ac..c0e2ff1c5c 100755 --- a/pkg/blobfuse-proxy/init.sh +++ b/pkg/blobfuse-proxy/init.sh @@ -26,99 +26,104 @@ HOST_CMD="nsenter --mount=/proc/1/ns/mnt" DISTRIBUTION=$($HOST_CMD cat /etc/os-release | grep ^ID= | cut -d'=' -f2 | tr -d '"') echo "Linux distribution: $DISTRIBUTION" +ARCH=$($HOST_CMD uname -m) +echo "Linux Arch is $(uname -m)" -if [ "${DISTRIBUTION}" = "ubuntu" ] && { [ "${INSTALL_BLOBFUSE}" = "true" ] || [ "${INSTALL_BLOBFUSE2}" = "true" ]; } +if [ "${ARCH}" != "aarch64" ] then - release=$($HOST_CMD lsb_release -rs) - echo "Ubuntu release: $release" - - if [ "$(expr "$release" \< "22.04")" -eq 1 ] + if [ "${DISTRIBUTION}" = "ubuntu" ] && { [ "${INSTALL_BLOBFUSE}" = "true" ] || [ "${INSTALL_BLOBFUSE2}" = "true" ]; } then - cp /blobfuse-proxy/packages-microsoft-prod-18.04.deb /host/etc/packages-microsoft-prod.deb - else - cp /blobfuse-proxy/packages-microsoft-prod-22.04.deb /host/etc/packages-microsoft-prod.deb - fi - - # when running dpkg -i /etc/packages-microsoft-prod.deb, need to enter y to continue. - # refer to https://stackoverflow.com/questions/45349571/how-to-install-deb-with-dpkg-non-interactively - yes | $HOST_CMD dpkg -i /etc/packages-microsoft-prod.deb && $HOST_CMD apt update - - pkg_list="" - if [ "${INSTALL_BLOBFUSE}" = "true" ] && [ "$(expr "$release" \< "22.04")" -eq 1 ] - then - pkg_list="${pkg_list} fuse" - # install blobfuse with latest version or specific version - if [ -z "${BLOBFUSE_VERSION}" ]; then - echo "install blobfuse with latest version" - pkg_list="${pkg_list} blobfuse" + release=$($HOST_CMD lsb_release -rs) + echo "Ubuntu release: $release" + + if [ "$(expr "$release" \< "22.04")" -eq 1 ] + then + cp /blobfuse-proxy/packages-microsoft-prod-18.04.deb /host/etc/packages-microsoft-prod.deb else - pkg_list="${pkg_list} blobfuse=${BLOBFUSE_VERSION}" + cp /blobfuse-proxy/packages-microsoft-prod-22.04.deb /host/etc/packages-microsoft-prod.deb fi - fi - - if [ "${INSTALL_BLOBFUSE2}" = "true" ] - then - if [ "$(expr "$release" \< "22.04")" -eq 1 ]; then - echo "install fuse for blobfuse2" + + # when running dpkg -i /etc/packages-microsoft-prod.deb, need to enter y to continue. + # refer to https://stackoverflow.com/questions/45349571/how-to-install-deb-with-dpkg-non-interactively + yes | $HOST_CMD dpkg -i /etc/packages-microsoft-prod.deb && $HOST_CMD apt update + + pkg_list="" + if [ "${INSTALL_BLOBFUSE}" = "true" ] && [ "$(expr "$release" \< "22.04")" -eq 1 ] + then pkg_list="${pkg_list} fuse" - else - echo "install fuse3 for blobfuse2, current release is $release" - pkg_list="${pkg_list} fuse3" + # install blobfuse with latest version or specific version + if [ -z "${BLOBFUSE_VERSION}" ]; then + echo "install blobfuse with latest version" + pkg_list="${pkg_list} blobfuse" + else + pkg_list="${pkg_list} blobfuse=${BLOBFUSE_VERSION}" + fi fi - # install blobfuse2 with latest version or specific version - if [ -z "${BLOBFUSE2_VERSION}" ]; then - echo "install blobfuse2 with latest version" - pkg_list="${pkg_list} blobfuse2" - else - pkg_list="${pkg_list} blobfuse2=${BLOBFUSE2_VERSION}" + if [ "${INSTALL_BLOBFUSE2}" = "true" ] + then + if [ "$(expr "$release" \< "22.04")" -eq 1 ]; then + echo "install fuse for blobfuse2" + pkg_list="${pkg_list} fuse" + else + echo "install fuse3 for blobfuse2, current release is $release" + pkg_list="${pkg_list} fuse3" + fi + + # install blobfuse2 with latest version or specific version + if [ -z "${BLOBFUSE2_VERSION}" ]; then + echo "install blobfuse2 with latest version" + pkg_list="${pkg_list} blobfuse2" + else + pkg_list="${pkg_list} blobfuse2=${BLOBFUSE2_VERSION}" + fi fi + echo "begin to install ${pkg_list}" + $HOST_CMD apt-get install -y $pkg_list + $HOST_CMD rm -f /etc/packages-microsoft-prod.deb fi - echo "begin to install ${pkg_list}" - $HOST_CMD apt-get install -y $pkg_list - $HOST_CMD rm -f /etc/packages-microsoft-prod.deb -fi -updateBlobfuseProxy="true" -if [ -f "/host/usr/bin/blobfuse-proxy" ];then - old=$(sha256sum /host/usr/bin/blobfuse-proxy | awk '{print $1}') - new=$(sha256sum /blobfuse-proxy/blobfuse-proxy | awk '{print $1}') - if [ "$old" = "$new" ];then - updateBlobfuseProxy="false" - echo "no need to update blobfuse-proxy" + updateBlobfuseProxy="true" + if [ -f "/host/usr/bin/blobfuse-proxy" ];then + old=$(sha256sum /host/usr/bin/blobfuse-proxy | awk '{print $1}') + new=$(sha256sum /blobfuse-proxy/blobfuse-proxy | awk '{print $1}') + if [ "$old" = "$new" ];then + updateBlobfuseProxy="false" + echo "no need to update blobfuse-proxy" + fi fi -fi -if [ "$updateBlobfuseProxy" = "true" ];then - echo "copy blobfuse-proxy...." - rm -rf /host/var/lib/kubelet/plugins/blob.csi.azure.com/blobfuse-proxy.sock - rm -rf /host/usr/bin/blobfuse-proxy - cp /blobfuse-proxy/blobfuse-proxy /host/usr/bin/blobfuse-proxy - chmod 755 /host/usr/bin/blobfuse-proxy -fi + if [ "$updateBlobfuseProxy" = "true" ];then + echo "copy blobfuse-proxy...." + rm -rf /host/var/lib/kubelet/plugins/blob.csi.azure.com/blobfuse-proxy.sock + rm -rf /host/usr/bin/blobfuse-proxy + cp /blobfuse-proxy/blobfuse-proxy /host/usr/bin/blobfuse-proxy + chmod 755 /host/usr/bin/blobfuse-proxy + fi -updateService="true" -if [ -f "/host/usr/lib/systemd/system/blobfuse-proxy.service" ];then - old=$(sha256sum /host/usr/lib/systemd/system/blobfuse-proxy.service | awk '{print $1}') - new=$(sha256sum /blobfuse-proxy/blobfuse-proxy.service | awk '{print $1}') - if [ "$old" = "$new" ];then - updateService="false" - echo "no need to update blobfuse-proxy.service" + updateService="true" + if [ -f "/host/usr/lib/systemd/system/blobfuse-proxy.service" ];then + old=$(sha256sum /host/usr/lib/systemd/system/blobfuse-proxy.service | awk '{print $1}') + new=$(sha256sum /blobfuse-proxy/blobfuse-proxy.service | awk '{print $1}') + if [ "$old" = "$new" ];then + updateService="false" + echo "no need to update blobfuse-proxy.service" + fi fi -fi -if [ "$updateService" = "true" ];then - echo "copy blobfuse-proxy.service...." - mkdir -p /host/usr/lib/systemd/system - cp /blobfuse-proxy/blobfuse-proxy.service /host/usr/lib/systemd/system/blobfuse-proxy.service -fi + if [ "$updateService" = "true" ];then + echo "copy blobfuse-proxy.service...." + mkdir -p /host/usr/lib/systemd/system + cp /blobfuse-proxy/blobfuse-proxy.service /host/usr/lib/systemd/system/blobfuse-proxy.service + fi -if [ "${INSTALL_BLOBFUSE_PROXY}" = "true" ];then - if [ "$updateBlobfuseProxy" = "true" ] || [ "$updateService" = "true" ];then - echo "start blobfuse-proxy...." - $HOST_CMD systemctl daemon-reload - $HOST_CMD systemctl enable blobfuse-proxy.service - $HOST_CMD systemctl restart blobfuse-proxy.service + if [ "${INSTALL_BLOBFUSE_PROXY}" = "true" ];then + if [ "$updateBlobfuseProxy" = "true" ] || [ "$updateService" = "true" ];then + echo "start blobfuse-proxy...." + $HOST_CMD systemctl daemon-reload + $HOST_CMD systemctl enable blobfuse-proxy.service + $HOST_CMD systemctl restart blobfuse-proxy.service + fi fi fi diff --git a/pkg/blobplugin/Dockerfile b/pkg/blobplugin/Dockerfile index 296e7aa9b0..24fc8b4541 100644 --- a/pkg/blobplugin/Dockerfile +++ b/pkg/blobplugin/Dockerfile @@ -30,12 +30,12 @@ RUN chmod +x /blobfuse-proxy/init.sh && \ RUN apt update && apt upgrade -y && apt-mark unhold libcap2 && clean-install ca-certificates uuid-dev util-linux mount udev wget e2fsprogs nfs-common netbase procps conntrack iptables bind9-host iproute2 bash netcat sysvinit-utils # install aznfs -RUN if [ "$TARGETARCH" = "amd64" ] ; then \ +RUN if [ "$ARCH" = "amd64" ] ; then \ wget -O aznfs.tar.gz https://github.com/Azure/AZNFS-mount/releases/download/1.0.8/aznfs-1.0.8-1.x86_64.tar.gz; \ else \ wget -O aznfs.tar.gz https://github.com/Azure/AZNFS-mount/releases/download/1.0.8/aznfs-1.0.8-1.arm64.tar.gz;fi RUN tar xvzf aznfs.tar.gz -C / && rm aznfs.tar.gz -ARG ARCH=amd64 + RUN if [ "$ARCH" = "amd64" ] ; then \ clean-install libcurl4-gnutls-dev && \ wget -O /blobfuse-proxy/packages-microsoft-prod-22.04.deb https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb && \