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

kubernetes-sigs / blob-csi-driver / 12561927214

31 Dec 2024 04:44PM UTC coverage: 74.335%. Remained the same
12561927214

Pull #1779

github

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

Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.22.1 to 2.22.2.
- [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.22.1...v2.22.2)

---
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 #1779: chore(deps): bump github.com/onsi/ginkgo/v2 from 2.22.1 to 2.22.2

2291 of 3082 relevant lines covered (74.33%)

7.1 hits per line

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

27.4
/pkg/blobplugin/main.go
1
/*
2
Copyright 2017 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 main
18

19
import (
20
        "context"
21
        "flag"
22
        "fmt"
23
        "net"
24
        "net/http"
25
        "os"
26
        "strings"
27

28
        "sigs.k8s.io/blob-csi-driver/pkg/blob"
29
        "sigs.k8s.io/blob-csi-driver/pkg/util"
30

31
        "k8s.io/component-base/metrics/legacyregistry"
32
        "k8s.io/klog/v2"
33
)
34

35
var driverOptions blob.DriverOptions
36
var (
37
        metricsAddress             = flag.String("metrics-address", "", "export the metrics")
38
        version                    = flag.Bool("version", false, "Print the version and exit.")
39
        endpoint                   = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
40
        kubeconfig                 = flag.String("kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
41
        cloudConfigSecretName      = flag.String("cloud-config-secret-name", "azure-cloud-provider", "secret name of cloud config")
42
        cloudConfigSecretNamespace = flag.String("cloud-config-secret-namespace", "kube-system", "secret namespace of cloud config")
43
        customUserAgent            = flag.String("custom-user-agent", "", "custom userAgent")
44
        userAgentSuffix            = flag.String("user-agent-suffix", "", "userAgent suffix")
45
        allowEmptyCloudConfig      = flag.Bool("allow-empty-cloud-config", true, "allow running driver without cloud config")
46
        kubeAPIQPS                 = flag.Float64("kube-api-qps", 25.0, "QPS to use while communicating with the kubernetes apiserver.")
47
        kubeAPIBurst               = flag.Int("kube-api-burst", 50, "Burst to use while communicating with the kubernetes apiserver.")
48
)
49

50
func init() {
1✔
51
        driverOptions.AddFlags()
1✔
52
}
1✔
53

54
// exit is a separate function to handle program termination
55
var exit = func(code int) {
×
56
        os.Exit(code)
×
57
}
×
58

59
func main() {
1✔
60
        klog.InitFlags(nil)
1✔
61
        _ = flag.Set("logtostderr", "true")
1✔
62
        flag.Parse()
1✔
63
        if *version {
2✔
64
                info, err := blob.GetVersionYAML(driverOptions.DriverName)
1✔
65
                if err != nil {
1✔
66
                        klog.Fatalln(err)
×
67
                }
×
68
                fmt.Println(info) // nolint
1✔
69
        } else {
×
70
                exportMetrics()
×
71
                handle()
×
72
        }
×
73
        exit(0)
1✔
74
}
75

76
func handle() {
×
77
        userAgent := blob.GetUserAgent(driverOptions.DriverName, *customUserAgent, *userAgentSuffix)
×
78
        klog.V(2).Infof("driver userAgent: %s", userAgent)
×
79

×
80
        kubeClient, err := util.GetKubeClient(*kubeconfig, *kubeAPIQPS, *kubeAPIBurst, userAgent)
×
81
        if err != nil {
×
82
                klog.Warningf("failed to get kubeClient, error: %v", err)
×
83
        }
×
84

85
        cloud, err := blob.GetCloudProvider(context.Background(), kubeClient, driverOptions.NodeID, *cloudConfigSecretName, *cloudConfigSecretNamespace, userAgent, *allowEmptyCloudConfig)
×
86
        if err != nil {
×
87
                klog.Fatalf("failed to get Azure Cloud Provider, error: %v", err)
×
88
        }
×
89
        klog.V(2).Infof("cloud: %s, location: %s, rg: %s, VnetName: %s, VnetResourceGroup: %s, SubnetName: %s", cloud.Cloud, cloud.Location, cloud.ResourceGroup, cloud.VnetName, cloud.VnetResourceGroup, cloud.SubnetName)
×
90

×
91
        driver := blob.NewDriver(&driverOptions, kubeClient, cloud)
×
92
        if driver == nil {
×
93
                klog.Fatalln("Failed to initialize Azure Blob Storage CSI driver")
×
94
        }
×
95
        if err := driver.Run(context.Background(), *endpoint); err != nil {
×
96
                klog.Fatalf("Failed to run Azure Blob Storage CSI driver: %v", err)
×
97
        }
×
98
}
99

100
func exportMetrics() {
×
101
        if *metricsAddress == "" {
×
102
                return
×
103
        }
×
104
        l, err := net.Listen("tcp", *metricsAddress)
×
105
        if err != nil {
×
106
                klog.Warningf("failed to get listener for metrics endpoint: %v", err)
×
107
                return
×
108
        }
×
109
        serve(context.Background(), l, serveMetrics)
×
110
}
111

112
func serve(_ context.Context, l net.Listener, serveFunc func(net.Listener) error) {
×
113
        path := l.Addr().String()
×
114
        klog.V(2).Infof("set up prometheus server on %v", path)
×
115
        go func() {
×
116
                defer l.Close()
×
117
                if err := serveFunc(l); err != nil {
×
118
                        klog.Fatalf("serve failure(%v), address(%v)", err, path)
×
119
                }
×
120
        }()
121
}
122

123
func serveMetrics(l net.Listener) error {
×
124
        m := http.NewServeMux()
×
125
        m.Handle("/metrics", legacyregistry.Handler()) //nolint, because azure cloud provider uses legacyregistry currently
×
126
        return trapClosedConnErr(http.Serve(l, m))
×
127
}
×
128

129
func trapClosedConnErr(err error) error {
3✔
130
        if err == nil {
4✔
131
                return nil
1✔
132
        }
1✔
133
        if strings.Contains(err.Error(), "use of closed network connection") {
3✔
134
                return nil
1✔
135
        }
1✔
136
        return err
1✔
137
}
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