mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-23 00:10:06 -05:00
cli: refuse to retry init once gRPC has reached READY one time
This commit is contained in:
parent
77d19eb896
commit
822d7823f8
@ -222,15 +222,22 @@ func (i *initCmd) initCall(ctx context.Context, dialer grpcDialer, ip string, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
type initDoer struct {
|
type initDoer struct {
|
||||||
dialer grpcDialer
|
dialer grpcDialer
|
||||||
endpoint string
|
endpoint string
|
||||||
req *initproto.InitRequest
|
req *initproto.InitRequest
|
||||||
resp *initproto.InitResponse
|
resp *initproto.InitResponse
|
||||||
log debugLog
|
log debugLog
|
||||||
spinner spinnerInterf
|
spinner spinnerInterf
|
||||||
|
connectedOnce bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *initDoer) Do(ctx context.Context) error {
|
func (d *initDoer) Do(ctx context.Context) error {
|
||||||
|
// connectedOnce is set in handleGRPCStateChanges when a connection was established in one retry attempt.
|
||||||
|
// This should cancel any other retry attempts when the connection is lost since the bootstrapper likely won't accept any new attempts anymore.
|
||||||
|
if d.connectedOnce {
|
||||||
|
return &nonRetriableError{errors.New("init already connected to the remote server in an previous attempt - resumption is not supported")}
|
||||||
|
}
|
||||||
|
|
||||||
conn, err := d.dialer.Dial(ctx, d.endpoint)
|
conn, err := d.dialer.Dial(ctx, d.endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.log.Debugf("Dialing init server failed: %w. Retrying...", err)
|
d.log.Debugf("Dialing init server failed: %w. Retrying...", err)
|
||||||
@ -266,6 +273,7 @@ func (d *initDoer) handleGRPCStateChanges(ctx context.Context, wg *sync.WaitGrou
|
|||||||
}
|
}
|
||||||
if state == connectivity.Ready {
|
if state == connectivity.Ready {
|
||||||
d.log.Debugf("Connection ready")
|
d.log.Debugf("Connection ready")
|
||||||
|
d.connectedOnce = true
|
||||||
d.spinner.Stop()
|
d.spinner.Stop()
|
||||||
d.spinner.Start("Initializing cluster ", false)
|
d.spinner.Start("Initializing cluster ", false)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user