@@ -18,14 +18,15 @@ import (
18
18
19
19
"github.com/cenkalti/backoff"
20
20
"github.com/hashicorp/go-multierror"
21
- "github.com/jetstack/preflight/api"
22
- "github.com/jetstack/preflight/pkg/client"
23
- "github.com/jetstack/preflight/pkg/datagatherer"
24
- "github.com/jetstack/preflight/pkg/version"
25
21
json "github.com/json-iterator/go"
26
22
"github.com/prometheus/client_golang/prometheus"
27
23
"github.com/prometheus/client_golang/prometheus/promhttp"
28
24
"github.com/spf13/cobra"
25
+
26
+ "github.com/jetstack/preflight/api"
27
+ "github.com/jetstack/preflight/pkg/client"
28
+ "github.com/jetstack/preflight/pkg/datagatherer"
29
+ "github.com/jetstack/preflight/pkg/version"
29
30
)
30
31
31
32
// ConfigFilePath is where the agent will try to load the configuration from
@@ -122,38 +123,32 @@ func Run(cmd *cobra.Command, args []string) {
122
123
log .Fatalf ("failed to instantiate %q data gatherer %q: %v" , kind , dgConfig .Name , err )
123
124
}
124
125
125
- wg . Add ( 1 )
126
+ log . Printf ( "starting %q datagatherer" , dgConfig . Name )
126
127
127
- go func () {
128
- log .Printf ("starting %q datagatherer" , dgConfig .Name )
129
-
130
- // start the data gatherers and wait for the cache sync
131
- if err := newDg .Run (ctx .Done ()); err != nil {
132
- log .Printf ("failed to start %q data gatherer %q: %v" , kind , dgConfig .Name , err )
133
- }
134
-
135
- // bootCtx is a context with a timeout to allow the informer 5
136
- // seconds to perform an initial sync. It may fail, and that's fine
137
- // too, it will backoff and retry of its own accord. Initial boot
138
- // will only be delayed by a max of 5 seconds.
139
- bootCtx , cancel := context .WithTimeout (ctx , 5 * time .Second )
140
- defer cancel ()
141
-
142
- // wait for the informer to complete an initial sync, we do this to
143
- // attempt to have an initial set of data for the first upload of
144
- // the run.
145
- if err := newDg .WaitForCacheSync (bootCtx .Done ()); err != nil {
146
- // log sync failure, this might recover in future
147
- log .Printf ("failed to complete initial sync of %q data gatherer %q: %v" , kind , dgConfig .Name , err )
148
- }
128
+ // start the data gatherers and wait for the cache sync
129
+ if err := newDg .Run (ctx .Done ()); err != nil {
130
+ log .Printf ("failed to start %q data gatherer %q: %v" , kind , dgConfig .Name , err )
131
+ }
149
132
150
- // regardless of success, this dataGatherers has been given a
151
- // chance to sync its cache and we will now continue as normal. We
152
- // assume at the informers will either recover or the log messages
153
- // above will help operators correct the issue.
154
- wg .Done ()
155
- }()
133
+ // bootCtx is a context with a timeout to allow the informer 5
134
+ // seconds to perform an initial sync. It may fail, and that's fine
135
+ // too, it will backoff and retry of its own accord. Initial boot
136
+ // will only be delayed by a max of 5 seconds.
137
+ bootCtx , cancel := context .WithTimeout (ctx , 5 * time .Second )
138
+ defer cancel ()
139
+
140
+ // wait for the informer to complete an initial sync, we do this to
141
+ // attempt to have an initial set of data for the first upload of
142
+ // the run.
143
+ if err := newDg .WaitForCacheSync (bootCtx .Done ()); err != nil {
144
+ // log sync failure, this might recover in future
145
+ log .Printf ("failed to complete initial sync of %q data gatherer %q: %v" , kind , dgConfig .Name , err )
146
+ }
156
147
148
+ // regardless of success, this dataGatherers has been given a
149
+ // chance to sync its cache and we will now continue as normal. We
150
+ // assume at the informers will either recover or the log messages
151
+ // above will help operators correct the issue.
157
152
dataGatherers [dgConfig .Name ] = newDg
158
153
}
159
154
0 commit comments