Skip to content

Commit 878483a

Browse files
committed
parse os-release
1 parent d0ef5fc commit 878483a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3590
-1257
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ require (
3838
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1
3939
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.0.0
4040
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1
41+
github.com/go-ini/ini v1.67.0
42+
github.com/pkg/errors v0.9.1
4143
github.com/satori/go.uuid v1.2.0
42-
github.com/zcalusic/sysinfo v0.9.5
4344
k8s.io/apiserver v0.25.2
4445
)
4546

@@ -86,7 +87,6 @@ require (
8687
github.com/opencontainers/runc v1.0.2 // indirect
8788
github.com/opencontainers/selinux v1.8.2 // indirect
8889
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect
89-
github.com/pkg/errors v0.9.1 // indirect
9090
github.com/pmezard/go-difflib v1.0.0 // indirect
9191
github.com/prometheus/client_golang v1.12.1 // indirect
9292
github.com/prometheus/client_model v0.2.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm
239239
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
240240
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
241241
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
242+
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
243+
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
242244
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
243245
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
244246
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
@@ -649,8 +651,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
649651
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
650652
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
651653
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
652-
github.com/zcalusic/sysinfo v0.9.5 h1:ivoHyj9aIAYkwzo1+8QgJ5s4oeE6Etx9FmZtqa4wJjQ=
653-
github.com/zcalusic/sysinfo v0.9.5/go.mod h1:Z/gPVufBrFc8X5sef3m6kkw3r3nlNFp+I6bvASfvBZQ=
654654
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
655655
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
656656
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=

pkg/blobfuse-proxy/main.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import (
2323

2424
"k8s.io/klog/v2"
2525

26-
"github.com/zcalusic/sysinfo"
26+
"github.com/go-ini/ini"
27+
"github.com/pkg/errors"
2728
server "sigs.k8s.io/blob-csi-driver/pkg/blobfuse-proxy/server"
2829
csicommon "sigs.k8s.io/blob-csi-driver/pkg/csi-common"
2930
)
@@ -64,11 +65,29 @@ func main() {
6465
}
6566
}
6667

68+
func getOSInfo() (map[string]string, error) {
69+
f := "/etc/lsb-release"
70+
cfg, err := ini.Load(f)
71+
if err != nil {
72+
return nil, errors.Wrapf(err, "failed to read %q", f)
73+
}
74+
75+
OSInfo := make(map[string]string)
76+
OSInfo["DISTRIB_ID"] = cfg.Section("").Key("DISTRIB_ID").String()
77+
OSInfo["DISTRIB_RELEASE"] = cfg.Section("").Key("DISTRIB_RELEASE").String()
78+
79+
return OSInfo, nil
80+
}
81+
6782
func getBlobfuseVersion() server.BlobfuseVersion {
68-
var si sysinfo.SysInfo
69-
si.GetSysInfo()
70-
klog.V(2).Infof("OS info: %+v", si.OS)
71-
if si.OS.Vendor == "ubuntu" && si.OS.Release >= "22.04" {
83+
OSInfo, err := getOSInfo()
84+
if err != nil {
85+
klog.Errorf("failed to get OS info: %v, default using blobfuse v1", err)
86+
return server.BlobfuseV1
87+
}
88+
klog.V(2).Infof("OS info: %v", OSInfo)
89+
90+
if OSInfo["DISTRIB_ID"] == "Ubuntu" && OSInfo["DISTRIB_RELEASE"] >= "22.04" {
7291
return server.BlobfuseV2
7392
}
7493
return server.BlobfuseV1

vendor/github.com/go-ini/ini/.editorconfig

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-ini/ini/.gitignore

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-ini/ini/.golangci.yml

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-ini/ini/LICENSE

Lines changed: 191 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-ini/ini/Makefile

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-ini/ini/README.md

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-ini/ini/codecov.yml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)