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

kubernetes-sigs / blob-csi-driver / 10512035464

22 Aug 2024 04:32PM UTC coverage: 73.88%. Remained the same
10512035464

Pull #1553

github

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

Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.19.1 to 2.20.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.19.1...v2.20.1)

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

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

2260 of 3059 relevant lines covered (73.88%)

7.09 hits per line

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

58.23
/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
        grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
28
        "google.golang.org/grpc"
29
        "k8s.io/klog/v2"
30
        "sigs.k8s.io/blob-csi-driver/pkg/blob"
31
        mount_azure_blob "sigs.k8s.io/blob-csi-driver/pkg/blobfuse-proxy/pb"
32
        "sigs.k8s.io/blob-csi-driver/pkg/util"
33
)
34

35
var (
36
        mutex sync.Mutex
37
)
38

39
type BlobfuseVersion int
40

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

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

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

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

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

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

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

104
func RunGRPCServer(
105
        mountServer mount_azure_blob.MountServiceServer,
106
        enableTLS bool,
107
        listener net.Listener,
108
) error {
×
109
        serverOptions := []grpc.ServerOption{
×
110
                grpc.ChainUnaryInterceptor(
×
111
                        grpcprom.NewServerMetrics().UnaryServerInterceptor(),
×
112
                ),
×
113
        }
×
114

×
115
        grpcServer := grpc.NewServer(serverOptions...)
×
116

×
117
        mount_azure_blob.RegisterMountServiceServer(grpcServer, mountServer)
×
118

×
119
        klog.V(2).Infof("Start GRPC server at %s, TLS = %t", listener.Addr().String(), enableTLS)
×
120
        return grpcServer.Serve(listener)
×
121
}
×
122

123
func getBlobfuseVersion() BlobfuseVersion {
1✔
124
        osinfo, err := util.GetOSInfo("/etc/os-release")
1✔
125
        if err != nil {
1✔
126
                klog.Warningf("failed to get OS info: %v, default using blobfuse v1", err)
×
127
                return BlobfuseV1
×
128
        }
×
129

130
        if (strings.EqualFold(osinfo.Distro, "mariner") || strings.EqualFold(osinfo.Distro, "azurelinux")) && osinfo.Version >= "2.0" {
1✔
131
                klog.V(2).Info("proxy default using blobfuse V2 for mounting on azurelinux(mariner) 2.0+")
×
132
                return BlobfuseV2
×
133
        }
×
134

135
        if strings.EqualFold(osinfo.Distro, "rhcos") {
1✔
136
                klog.V(2).Info("proxy default using blobfuse V2 for mounting on RHCOS")
×
137
                return BlobfuseV2
×
138
        }
×
139

140
        if strings.EqualFold(osinfo.Distro, "ubuntu") && osinfo.Version >= "22.04" {
2✔
141
                klog.V(2).Info("proxy default using blobfuse V2 for mounting on Ubuntu 22.04+")
1✔
142
                return BlobfuseV2
1✔
143
        }
1✔
144

145
        klog.V(2).Info("proxy default using blobfuse V1 for mounting")
×
146
        return BlobfuseV1
×
147
}
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