@@ -17,7 +17,6 @@ import (
17
17
"github.com/loft-sh/vcluster/pkg/etcd"
18
18
"github.com/loft-sh/vcluster/pkg/pro"
19
19
"github.com/loft-sh/vcluster/pkg/util/commandwriter"
20
- "golang.org/x/sync/errgroup"
21
20
"k8s.io/apimachinery/pkg/util/wait"
22
21
"k8s.io/klog/v2"
23
22
)
@@ -30,7 +29,7 @@ func StartK8S(
30
29
scheduler vclusterconfig.DistroContainer ,
31
30
vConfig * config.VirtualClusterConfig ,
32
31
) error {
33
- eg := & errgroup. Group {}
32
+ errChan := make ( chan error , 1 )
34
33
35
34
// start the backing store
36
35
etcdEndpoints , etcdCertificates , err := StartBackingStore (ctx , vConfig )
@@ -40,7 +39,7 @@ func StartK8S(
40
39
41
40
// start api server first
42
41
if apiServer .Enabled {
43
- eg . Go ( func () error {
42
+ go func () {
44
43
// build flags
45
44
issuer := "https://kubernetes.default.svc.cluster.local"
46
45
@@ -89,12 +88,13 @@ func StartK8S(
89
88
// wait until etcd is up and running
90
89
err := etcd .WaitForEtcd (ctx , etcdCertificates , etcdEndpoints )
91
90
if err != nil {
92
- return err
91
+ errChan <- err
92
+ return
93
93
}
94
94
95
95
// now start the api server
96
- return RunCommand (ctx , args , "apiserver" )
97
- })
96
+ errChan <- RunCommand (ctx , args , "apiserver" )
97
+ }( )
98
98
}
99
99
100
100
// wait for api server to be up as otherwise controller and scheduler might fail
@@ -105,7 +105,7 @@ func StartK8S(
105
105
106
106
// start controller command
107
107
if controllerManager .Enabled {
108
- eg . Go ( func () error {
108
+ go func () {
109
109
// build flags
110
110
args := []string {}
111
111
if len (controllerManager .Command ) > 0 {
@@ -145,13 +145,13 @@ func StartK8S(
145
145
146
146
// add extra args
147
147
args = append (args , controllerManager .ExtraArgs ... )
148
- return RunCommand (ctx , args , "controller-manager" )
149
- })
148
+ errChan <- RunCommand (ctx , args , "controller-manager" )
149
+ }( )
150
150
}
151
151
152
152
// start scheduler command
153
153
if vConfig .ControlPlane .Advanced .VirtualScheduler .Enabled {
154
- eg . Go ( func () error {
154
+ go func () {
155
155
// build flags
156
156
args := []string {}
157
157
if len (scheduler .Command ) > 0 {
@@ -171,18 +171,11 @@ func StartK8S(
171
171
172
172
// add extra args
173
173
args = append (args , scheduler .ExtraArgs ... )
174
- return RunCommand (ctx , args , "scheduler" )
175
- })
174
+ errChan <- RunCommand (ctx , args , "scheduler" )
175
+ }( )
176
176
}
177
177
178
- // regular stop case, will return as soon as a component returns an error.
179
- // we don't expect the components to stop by themselves since they're supposed
180
- // to run until killed or until they fail
181
- err = eg .Wait ()
182
- if err == nil || err .Error () == "signal: killed" {
183
- return nil
184
- }
185
- return err
178
+ return <- errChan
186
179
}
187
180
188
181
func StartKine (ctx context.Context , dataSource , listenAddress string , certificates * etcd.Certificates ) {
@@ -300,7 +293,7 @@ func RunCommand(ctx context.Context, command []string, component string) error {
300
293
301
294
// make sure we wait for scanner to be done
302
295
writer .CloseAndWait (ctx , err )
303
- return err
296
+ return fmt . Errorf ( "error running command %s: %w" , command [ 0 ], err )
304
297
}
305
298
306
299
// waits for the api to be up, ignoring certs and calling it
0 commit comments