diff --git a/charts/latest/blob-csi-driver-v0.0.0.tgz b/charts/latest/blob-csi-driver-v0.0.0.tgz index 94af9f8ba..d0b720c63 100644 Binary files a/charts/latest/blob-csi-driver-v0.0.0.tgz and b/charts/latest/blob-csi-driver-v0.0.0.tgz differ diff --git a/charts/latest/blob-csi-driver/templates/csi-blob-node.yaml b/charts/latest/blob-csi-driver/templates/csi-blob-node.yaml index f0f5118fd..702c765aa 100644 --- a/charts/latest/blob-csi-driver/templates/csi-blob-node.yaml +++ b/charts/latest/blob-csi-driver/templates/csi-blob-node.yaml @@ -66,7 +66,6 @@ spec: tolerations: {{ toYaml . | indent 8 }} {{- end }} -{{- if .Values.node.enableBlobfuseProxy }} initContainers: - name: install-blobfuse-proxy {{- if hasPrefix "/" .Values.image.blob.repository }} @@ -90,6 +89,8 @@ spec: value: "{{ .Values.node.blobfuseProxy.installBlobfuse2 }}" - name: BLOBFUSE2_VERSION value: "{{ .Values.node.blobfuseProxy.blobfuse2Version }}" + - name: INSTALL_BLOBFUSE_PROXY + value: "{{ .Values.node.enableBlobfuseProxy }}" - name: SET_MAX_OPEN_FILE_NUM value: "{{ .Values.node.blobfuseProxy.setMaxOpenFileNum }}" - name: MAX_FILE_NUM @@ -99,9 +100,10 @@ spec: volumeMounts: - name: host-usr mountPath: /host/usr + - name: host-usr-local + mountPath: /host/usr/local - name: host-etc mountPath: /host/etc -{{- end }} containers: - name: liveness-probe imagePullPolicy: {{ .Values.image.livenessProbe.pullPolicy }} @@ -266,14 +268,15 @@ spec: name: mountpoint-dir {{- end }} volumes: -{{- if .Values.node.enableBlobfuseProxy }} - name: host-usr hostPath: path: /usr + - name: host-usr-local + hostPath: + path: /usr/local - name: host-etc hostPath: path: /etc -{{- end }} - hostPath: path: {{ .Values.linux.kubelet }}/plugins/{{ .Values.driver.name }} type: DirectoryOrCreate diff --git a/charts/latest/blob-csi-driver/values.yaml b/charts/latest/blob-csi-driver/values.yaml index 6c50eb6b8..13580fde8 100644 --- a/charts/latest/blob-csi-driver/values.yaml +++ b/charts/latest/blob-csi-driver/values.yaml @@ -115,7 +115,7 @@ node: livenessProbe: healthPort: 29633 logLevel: 5 - enableBlobfuseProxy: false + enableBlobfuseProxy: true blobfuseProxy: installBlobfuse: true blobfuseVersion: "1.4.5" diff --git a/deploy/csi-blob-node.yaml b/deploy/csi-blob-node.yaml index fc7ff901d..8172d4dcf 100644 --- a/deploy/csi-blob-node.yaml +++ b/deploy/csi-blob-node.yaml @@ -68,6 +68,8 @@ spec: volumeMounts: - name: host-usr mountPath: /host/usr + - name: host-usr-local + mountPath: /host/usr/local - name: host-etc mountPath: /host/etc containers: @@ -178,6 +180,9 @@ spec: - name: host-usr hostPath: path: /usr + - name: host-usr-local + hostPath: + path: /usr/local - name: host-etc hostPath: path: /etc diff --git a/pkg/blobfuse-proxy/init.sh b/pkg/blobfuse-proxy/init.sh index 380f2beca..4628f5ae4 100755 --- a/pkg/blobfuse-proxy/init.sh +++ b/pkg/blobfuse-proxy/init.sh @@ -25,110 +25,32 @@ READ_AHEAD_KB=${READ_AHEAD_KB:-15380} 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" ]; } -then - 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 - 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" - else - pkg_list="${pkg_list} blobfuse=${BLOBFUSE_VERSION}" - fi - fi - - 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 - -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 - -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" - 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 [ "${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 - +echo "Linux distribution: $DISTRIBUTION, Arch: $ARCH" + +# install blobfuse-proxy and blobfuse/blofuse2 if needed +case "${DISTRIBUTION}" in + "ubuntu") + . ./blobfuse-proxy/install-proxy-ubuntu.sh + ;; + "rhcos") + . ./blobfuse-proxy/install-proxy-rhcos.sh + ;; + "mariner") + . ./blobfuse-proxy/install-proxy-mariner.sh + ;; + *) + echo "Unsupported distribution: ${DISTRIBUTION}" + ;; +esac + +# set max open file num if [ "${SET_MAX_OPEN_FILE_NUM}" = "true" ] then $HOST_CMD sysctl -w fs.file-max="${MAX_FILE_NUM}" fi +# disable updatedb updateDBConfigPath="/host/etc/updatedb.conf" if [ "${DISABLE_UPDATEDB}" = "true" ] && [ -f ${updateDBConfigPath} ] then @@ -140,6 +62,7 @@ then cat ${updateDBConfigPath} fi +# set read ahead size if [ "${SET_READ_AHEAD_SIZE}" = "true" ] then echo "set read ahead size to ${READ_AHEAD_KB}KB" diff --git a/pkg/blobfuse-proxy/install-proxy-mariner.sh b/pkg/blobfuse-proxy/install-proxy-mariner.sh new file mode 100644 index 000000000..4f7382708 --- /dev/null +++ b/pkg/blobfuse-proxy/install-proxy-mariner.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# Copyright 2019 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xe + +# install blobfuse/blobfuse2 +echo "skip install blobfuse/blobfuse2 for mariner...." + +# install 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 +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" + 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 [ "${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 diff --git a/pkg/blobfuse-proxy/install-proxy-rhcos.sh b/pkg/blobfuse-proxy/install-proxy-rhcos.sh new file mode 100644 index 000000000..91f51f8bc --- /dev/null +++ b/pkg/blobfuse-proxy/install-proxy-rhcos.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +# Copyright 2019 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xe + +# in coreos, we could just copy the blobfuse2 binary to /usr/local/bin/blobfuse2 +if [ "${INSTALL_BLOBFUSE}" = "true" ] || [ "${INSTALL_BLOBFUSE2}" = "true" ] +then + echo "copy blobfuse2...." + cp /usr/bin/blobfuse2 /host/usr/local/bin/blobfuse2 +fi + +# install blobfuse-proxy +updateBlobfuseProxy="true" +if [ -f "/host/usr/local/bin/blobfuse-proxy" ];then + old=$(sha256sum /host/usr/local/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 +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/local/bin/blobfuse-proxy + cp /blobfuse-proxy/blobfuse-proxy /host/usr/local/bin/blobfuse-proxy + chmod 755 /host/usr/local/bin/blobfuse-proxy +fi + +updateService="true" +echo "change from /usr/bin/blobfuse-proxy to /usr/local/bin/blobfuse-proxy in blobfuse-proxy.service" +sed -i 's/\/usr\/bin\/blobfuse-proxy/\/usr\/local\/bin\/blobfuse-proxy/g' /blobfuse-proxy/blobfuse-proxy.service +if [ -f "/host/etc/systemd/system/blobfuse-proxy.service" ];then + old=$(sha256sum /host/etc/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 +if [ "$updateService" = "true" ];then + echo "copy blobfuse-proxy.service...." + mkdir -p /host/etc/systemd/system/ + cp /blobfuse-proxy/blobfuse-proxy.service /host/etc/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 + fi +fi diff --git a/pkg/blobfuse-proxy/install-proxy-ubuntu.sh b/pkg/blobfuse-proxy/install-proxy-ubuntu.sh new file mode 100644 index 000000000..911be8356 --- /dev/null +++ b/pkg/blobfuse-proxy/install-proxy-ubuntu.sh @@ -0,0 +1,117 @@ +#!/bin/sh + +# Copyright 2019 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xe + +# install blobfuse/blobfuse2 +if [ "${ARCH}" = "aarch64" ] +then + echo "skip install blobfuse/blobfuse2 for arm64...." +elif [ "${INSTALL_BLOBFUSE}" = "true" ] || [ "${INSTALL_BLOBFUSE2}" = "true" ] +then + echo "start to install blobfuse/blobfuse2...." + + 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 + 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="" + # blobfuse + if [ "${INSTALL_BLOBFUSE}" = "true" ] && [ "$(expr "$release" \< "22.04")" -eq 1 ] + then + pkg_list="${pkg_list} fuse" + 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 + + # blobfuse2 + 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 + + 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 + +# install 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 +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" + 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 [ "${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 diff --git a/pkg/blobfuse-proxy/server/server.go b/pkg/blobfuse-proxy/server/server.go index 19c89c6f0..c93ec6505 100644 --- a/pkg/blobfuse-proxy/server/server.go +++ b/pkg/blobfuse-proxy/server/server.go @@ -115,14 +115,24 @@ func RunGRPCServer( } func getBlobfuseVersion() BlobfuseVersion { - osinfo, err := util.GetOSInfo("/etc/lsb-release") + osinfo, err := util.GetOSInfo("/etc/os-release") if err != nil { klog.Warningf("failed to get OS info: %v, default using blobfuse v1", err) return BlobfuseV1 } - if osinfo.Distro == "Ubuntu" && osinfo.Version >= "22.04" { - klog.V(2).Info("proxy default using blobfuse V2 for mounting") + if strings.EqualFold(osinfo.Distro, "mariner") && osinfo.Version >= "2.0" { + klog.V(2).Info("proxy default using blobfuse V2 for mounting on Mariner 2.0+") + return BlobfuseV2 + } + + if strings.EqualFold(osinfo.Distro, "rhcos") { + klog.V(2).Info("proxy default using blobfuse V2 for mounting on RHCOS") + return BlobfuseV2 + } + + if strings.EqualFold(osinfo.Distro, "ubuntu") && osinfo.Version >= "22.04" { + klog.V(2).Info("proxy default using blobfuse V2 for mounting on Ubuntu 22.04+") return BlobfuseV2 } diff --git a/pkg/blobplugin/Dockerfile b/pkg/blobplugin/Dockerfile index 159e0c594..efff57ee4 100644 --- a/pkg/blobplugin/Dockerfile +++ b/pkg/blobplugin/Dockerfile @@ -21,10 +21,16 @@ COPY ${binary} /blobplugin RUN mkdir /blobfuse-proxy/ COPY ./pkg/blobfuse-proxy/init.sh /blobfuse-proxy/ +COPY ./pkg/blobfuse-proxy/install-proxy-ubuntu.sh /blobfuse-proxy/ +COPY ./pkg/blobfuse-proxy/install-proxy-rhcos.sh /blobfuse-proxy/ +COPY ./pkg/blobfuse-proxy/install-proxy-mariner.sh /blobfuse-proxy/ COPY ./pkg/blobfuse-proxy/blobfuse-proxy.service /blobfuse-proxy/ COPY ./_output/${ARCH}/blobfuse-proxy /blobfuse-proxy/ RUN chmod +x /blobfuse-proxy/init.sh && \ + chmod +x /blobfuse-proxy/install-proxy-ubuntu.sh && \ + chmod +x /blobfuse-proxy/install-proxy-rhcos.sh && \ + chmod +x /blobfuse-proxy/install-proxy-mariner.sh && \ chmod +x /blobfuse-proxy/blobfuse-proxy.service && \ chmod +x /blobfuse-proxy/blobfuse-proxy diff --git a/pkg/util/util.go b/pkg/util/util.go index 352891d6d..691d2a299 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -177,8 +177,8 @@ type OsInfo struct { } const ( - keyDistribID = "DISTRIB_ID" - keyDistribRelease = "DISTRIB_RELEASE" + keyID = "ID" + keyVersionID = "VERSION_ID" ) func GetOSInfo(f interface{}) (*OsInfo, error) { @@ -188,8 +188,8 @@ func GetOSInfo(f interface{}) (*OsInfo, error) { } oi := &OsInfo{} - oi.Distro = cfg.Section("").Key(keyDistribID).String() - oi.Version = cfg.Section("").Key(keyDistribRelease).String() + oi.Distro = cfg.Section("").Key(keyID).String() + oi.Version = cfg.Section("").Key(keyVersionID).String() klog.V(2).Infof("get OS info: %v", oi) return oi, nil diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index bbef8755b..211460862 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -272,10 +272,10 @@ func TestGetOSInfo(t *testing.T) { { name: "parse os info correctly", args: args{ - f: []byte("DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=22.04"), + f: []byte("ID=ubuntu\nVERSION_ID=\"22.04\""), }, want: &OsInfo{ - Distro: "Ubuntu", + Distro: "ubuntu", Version: "22.04", }, wantErr: false,