Skip to content
This repository was archived by the owner on Mar 22, 2025. It is now read-only.

Commit c93d325

Browse files
committed
Removes the influx ping as the services starts up too slowly
1 parent 0da3669 commit c93d325

File tree

2 files changed

+0
-30
lines changed

2 files changed

+0
-30
lines changed

collector/startup_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
var errNotImplemented = fmt.Errorf("method not implemented")
1616

1717
type mockInflux struct {
18-
pingErr bool
19-
pingRun bool
2018
closeCh chan bool
2119
}
2220

@@ -34,12 +32,6 @@ func (i *mockInflux) Health(ctx context.Context) (*domain.HealthCheck, error) {
3432
return nil, errNotImplemented
3533
}
3634
func (i *mockInflux) Ping(ctx context.Context) (bool, error) {
37-
switch {
38-
case i.pingErr:
39-
return false, errNotImplemented
40-
case i.pingRun:
41-
return false, nil
42-
}
4335
return true, nil
4436
}
4537
func (i *mockInflux) Close() {
@@ -101,20 +93,6 @@ func TestStartup(t *testing.T) {
10193
}
10294
ua.CollectionPeriod = goodPeriod
10395

104-
// Bad case: error while pinging influxdb server
105-
ua.influx = &mockInflux{pingErr: true}
106-
err = ua.startup()
107-
if err == nil {
108-
t.Fatalf("Expected error, got nil")
109-
}
110-
111-
// Bad case: influxdb not running when pinging
112-
ua.influx = &mockInflux{pingRun: true}
113-
err = ua.startup()
114-
if err == nil {
115-
t.Fatalf("Expected error, got nil")
116-
}
117-
11896
// Good case: startup() enters loop and can be shut down again
11997
c := make(chan bool)
12098
ua.influx = &mockInflux{closeCh: c}

collector/unitasset.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,6 @@ func (ua *unitAsset) startup() (err error) {
164164
return errTooShortPeriod
165165
}
166166

167-
// Make sure we can contact the influxdb server, before trying to do any thing else
168-
running, err := ua.influx.Ping(ua.Owner.Ctx)
169-
if err != nil {
170-
return fmt.Errorf("ping influxdb: %w", err)
171-
} else if !running {
172-
return fmt.Errorf("influxdb not running")
173-
}
174-
175167
for {
176168
select {
177169
// Wait for a shutdown signal

0 commit comments

Comments
 (0)