Skip to content

Commit 46c632c

Browse files
committed
USHIFT-5297: Rework run loop
1 parent 2f87446 commit 46c632c

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

pkg/controllers/telemetry.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ func (t *TelemetryManager) Dependencies() []string {
5050

5151
func (t *TelemetryManager) Run(ctx context.Context, ready chan<- struct{}, stopped chan<- struct{}) error {
5252
defer close(stopped)
53+
defer close(ready)
54+
55+
if t.config.Telemetry.Status == config.StatusDisabled {
56+
return nil
57+
}
5358

5459
clusterId, err := getClusterId()
5560
if err != nil {
@@ -60,21 +65,6 @@ func (t *TelemetryManager) Run(ctx context.Context, ready chan<- struct{}, stopp
6065
return fmt.Errorf("unable to get pull secret: %v", err)
6166
}
6267

63-
panicChannel := make(chan any, 1)
64-
go func() {
65-
defer func() {
66-
if r := recover(); r != nil {
67-
panicChannel <- r
68-
}
69-
}()
70-
}()
71-
72-
close(ready)
73-
74-
if t.config.Telemetry.Status == config.StatusDisabled {
75-
return nil
76-
}
77-
7868
_ = telemetry.NewTelemetryClient(t.config.Telemetry.Endpoint, clusterId, pullSecret)
7969
go func() {
8070
klog.Infof("First metrics collection")
@@ -88,8 +78,7 @@ func (t *TelemetryManager) Run(ctx context.Context, ready chan<- struct{}, stopp
8878
}
8979
}
9080
}()
91-
perr := <-panicChannel
92-
panic(perr)
81+
return nil
9382
}
9483

9584
func getClusterId() (string, error) {

0 commit comments

Comments
 (0)