Skip to content

Commit 470839e

Browse files
authored
Addressing the use of "deprecated" (#985)
https://pkg.go.dev/google.golang.org/grpc#DialContext, for the recommended function and fix docs for unix and tcp "monitor" behaviour #952
1 parent bb21f6d commit 470839e

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,15 @@ To use it, you have to start your exporter with the following flag `--internal-m
346346
You can whether use a TCP or UNIX socket eg:
347347

348348
```
349-
~$ gitlab-ci-pipelines-exporter -m 'unix://gcpe-monitor.sock' run
349+
~$ gitlab-ci-pipelines-exporter -m 'unix:///gcpe-monitor.sock' run
350350
~$ gitlab-ci-pipelines-exporter -m 'tcp://127.0.0.1:9000' run
351351
```
352352

353-
To use the monitor CLI, you need to be able to access the monitoring socket and reuse the same flag:
353+
Unix socket address format is denoted here: https://github.com/grpc/grpc/blob/master/doc/naming.md#detailed-design
354354

355+
To use the monitor CLI, you need to be able to access the monitoring socket and reuse the same flag:
355356
```
356-
export GCPE_INTERNAL_MONITORING_LISTENER_ADDRESS='unix://gcpe-monitor.sock'
357+
export GCPE_INTERNAL_MONITORING_LISTENER_ADDRESS='unix:///gcpe-monitor.sock'
357358
~$ gitlab-ci-pipelines-exporter run &
358359
~$ gitlab-ci-pipelines-exporter monitor
359360
```

pkg/monitor/client/client.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package client
22

33
import (
4-
"context"
54
"net/url"
65

76
log "github.com/sirupsen/logrus"
@@ -17,12 +16,17 @@ type Client struct {
1716
}
1817

1918
// NewClient ..
20-
func NewClient(ctx context.Context, endpoint *url.URL) *Client {
19+
func NewClient(endpoint *url.URL) *Client {
2120
log.WithField("endpoint", endpoint.String()).Debug("establishing gRPC connection to the server..")
2221

23-
conn, err := grpc.DialContext(
24-
ctx,
25-
endpoint.String(),
22+
target_address := endpoint.String()
23+
if endpoint.Scheme != "unix" {
24+
// Drop the schema and just use "host:port" if we're dealing with local addresses
25+
target_address = endpoint.Host
26+
}
27+
28+
conn, err := grpc.NewClient(
29+
target_address,
2630
grpc.WithTransportCredentials(insecure.NewCredentials()),
2731
)
2832
if err != nil {

pkg/monitor/ui/ui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func newModel(version string, endpoint *url.URL) (m *model) {
225225
vp: viewport.Model{},
226226
telemetryStream: make(chan *pb.Telemetry),
227227
progress: &p,
228-
client: client.NewClient(context.TODO(), endpoint),
228+
client: client.NewClient(endpoint),
229229
}
230230

231231
return

0 commit comments

Comments
 (0)