• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kubernetes-sigs / blob-csi-driver / 6947043498

21 Nov 2023 04:52PM UTC coverage: 80.422%. Remained the same
6947043498

Pull #1123

github

web-flow
chore(deps): bump github.com/onsi/ginkgo/v2 from 2.13.0 to 2.13.1

Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.13.0 to 2.13.1.
- [Release notes](https://github.com/onsi/ginkgo/releases)
- [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/onsi/ginkgo/compare/v2.13.0...v2.13.1)

---
updated-dependencies:
- dependency-name: github.com/onsi/ginkgo/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #1123: chore(deps): bump github.com/onsi/ginkgo/v2 from 2.13.0 to 2.13.1

1980 of 2462 relevant lines covered (80.42%)

7.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.16
/pkg/blobfuse-proxy/server/server.go
1
/*
2
Copyright 2021 The Kubernetes Authors.
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
package server
18

19
import (
20
        "context"
21
        "fmt"
22
        "net"
23
        "os/exec"
24
        "strings"
25
        "sync"
26

27
        "google.golang.org/grpc"
28
        "k8s.io/klog/v2"
29
        "sigs.k8s.io/blob-csi-driver/pkg/blob"
30
        mount_azure_blob "sigs.k8s.io/blob-csi-driver/pkg/blobfuse-proxy/pb"
31
        "sigs.k8s.io/blob-csi-driver/pkg/util"
32
)
33

34
var (
35
        mutex sync.Mutex
36
)
37

38
type BlobfuseVersion int
39

40
const (
41
        BlobfuseV1 BlobfuseVersion = iota
42
        BlobfuseV2
43
)
44

45
type MountServer struct {
46
        blobfuseVersion BlobfuseVersion
47
        mount_azure_blob.UnimplementedMountServiceServer
48
}
49

50
// NewMountServer returns a new Mountserver
51
func NewMountServiceServer() *MountServer {
1✔
52
        mountServer := &MountServer{}
1✔
53
        mountServer.blobfuseVersion = getBlobfuseVersion()
1✔
54
        return mountServer
1✔
55
}
1✔
56

57
// MountAzureBlob mounts an azure blob container to given location
58
func (server *MountServer) MountAzureBlob(_ context.Context,
59
        req *mount_azure_blob.MountAzureBlobRequest,
60
) (resp *mount_azure_blob.MountAzureBlobResponse, err error) {
1✔
61
        mutex.Lock()
1✔
62
        defer mutex.Unlock()
1✔
63

1✔
64
        args := req.GetMountArgs()
1✔
65
        authEnv := req.GetAuthEnv()
1✔
66
        protocol := req.GetProtocol()
1✔
67
        klog.V(2).Infof("received mount request: protocol: %s, server default blobfuseVersion: %v, mount args %v \n", protocol, server.blobfuseVersion, args)
1✔
68

1✔
69
        var cmd *exec.Cmd
1✔
70
        var result mount_azure_blob.MountAzureBlobResponse
1✔
71
        if protocol == blob.Fuse2 || server.blobfuseVersion == BlobfuseV2 {
2✔
72
                args = "mount " + args
1✔
73
                // add this arg for blobfuse2 to solve the issue:
1✔
74
                // https://github.com/Azure/azure-storage-fuse/issues/1015
1✔
75
                if !strings.Contains(args, "--ignore-open-flags") {
2✔
76
                        klog.V(2).Infof("append --ignore-open-flags=true to mount args")
1✔
77
                        args = args + " " + "--ignore-open-flags=true"
1✔
78
                }
1✔
79
                args = util.TrimDuplicatedSpace(args)
1✔
80
                klog.V(2).Infof("mount with v2, protocol: %s, args: %s", protocol, args)
1✔
81
                cmd = exec.Command("blobfuse2", strings.Split(args, " ")...)
1✔
82
        } else {
×
83
                args = util.TrimDuplicatedSpace(args)
×
84
                klog.V(2).Infof("mount with v1, protocol: %s, args: %s", protocol, args)
×
85
                cmd = exec.Command("blobfuse", strings.Split(args, " ")...)
×
86
        }
×
87

88
        cmd.Env = append(cmd.Env, authEnv...)
1✔
89
        output, err := cmd.CombinedOutput()
1✔
90
        if err != nil {
2✔
91
                klog.Error("blobfuse mount failed: with error:", err.Error())
1✔
92
        } else {
1✔
93
                klog.V(2).Infof("successfully mounted")
×
94
        }
×
95
        result.Output = string(output)
1✔
96
        klog.V(2).Infof("blobfuse output: %s\n", result.Output)
1✔
97
        if err != nil {
2✔
98
                return &result, fmt.Errorf("%w %s", err, result.Output)
1✔
99
        }
1✔
100
        return &result, nil
×
101
}
102

103
func RunGRPCServer(
104
        mountServer mount_azure_blob.MountServiceServer,
105
        enableTLS bool,
106
        listener net.Listener,
107
) error {
×
108
        serverOptions := []grpc.ServerOption{}
×
109
        grpcServer := grpc.NewServer(serverOptions...)
×
110

×
111
        mount_azure_blob.RegisterMountServiceServer(grpcServer, mountServer)
×
112

×
113
        klog.V(2).Infof("Start GRPC server at %s, TLS = %t", listener.Addr().String(), enableTLS)
×
114
        return grpcServer.Serve(listener)
×
115
}
×
116

117
func getBlobfuseVersion() BlobfuseVersion {
1✔
118
        osinfo, err := util.GetOSInfo("/etc/os-release")
1✔
119
        if err != nil {
1✔
120
                klog.Warningf("failed to get OS info: %v, default using blobfuse v1", err)
×
121
                return BlobfuseV1
×
122
        }
×
123

124
        if strings.EqualFold(osinfo.Distro, "mariner") && osinfo.Version >= "2.0" {
1✔
125
                klog.V(2).Info("proxy default using blobfuse V2 for mounting on Mariner 2.0+")
×
126
                return BlobfuseV2
×
127
        }
×
128

129
        if strings.EqualFold(osinfo.Distro, "rhcos") {
1✔
130
                klog.V(2).Info("proxy default using blobfuse V2 for mounting on RHCOS")
×
131
                return BlobfuseV2
×
132
        }
×
133

134
        if strings.EqualFold(osinfo.Distro, "ubuntu") && osinfo.Version >= "22.04" {
2✔
135
                klog.V(2).Info("proxy default using blobfuse V2 for mounting on Ubuntu 22.04+")
1✔
136
                return BlobfuseV2
1✔
137
        }
1✔
138

139
        klog.V(2).Info("proxy default using blobfuse V1 for mounting")
×
140
        return BlobfuseV1
×
141
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc