Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvz committed Oct 18, 2023
1 parent 6270feb commit bd1e028
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/blobfuse-proxy/install-proxy-rhcos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

set -xe

# install blobfuse2
# 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...."
Expand Down
16 changes: 13 additions & 3 deletions pkg/blobfuse-proxy/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ type OsInfo struct {
}

const (
keyDistribID = "DISTRIB_ID"
keyDistribRelease = "DISTRIB_RELEASE"
keyID = "ID"
keyVersionID = "VERSION_ID"
)

func GetOSInfo(f interface{}) (*OsInfo, error) {
Expand All @@ -178,8 +178,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
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,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,
Expand Down

0 comments on commit bd1e028

Please sign in to comment.