mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
Add warning about non retriable error during init (#644)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
e76a87fcfc
commit
1968dfe70c
2 changed files with 40 additions and 3 deletions
|
@ -9,6 +9,7 @@ package cmd
|
|||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
|
@ -141,6 +142,11 @@ func initialize(cmd *cobra.Command, newDialer func(validator *cloudcmd.Validator
|
|||
resp, err := initCall(cmd.Context(), newDialer(validator), idFile.IP, req)
|
||||
spinner.Stop()
|
||||
if err != nil {
|
||||
var nonRetriable *nonRetriableError
|
||||
if errors.As(err, &nonRetriable) {
|
||||
cmd.PrintErrln("Cluster initialization failed. This error is not recoverable.")
|
||||
cmd.PrintErrln("Terminate your cluster and try again.")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -181,7 +187,7 @@ func (d *initDoer) Do(ctx context.Context) error {
|
|||
protoClient := initproto.NewAPIClient(conn)
|
||||
resp, err := protoClient.Init(ctx, d.req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("init call: %w", err)
|
||||
return &nonRetriableError{fmt.Errorf("init call: %w", err)}
|
||||
}
|
||||
d.resp = resp
|
||||
return nil
|
||||
|
@ -339,3 +345,17 @@ func getMarshaledServiceAccountURI(provider cloudprovider.Provider, config *conf
|
|||
type grpcDialer interface {
|
||||
Dial(ctx context.Context, target string) (*grpc.ClientConn, error)
|
||||
}
|
||||
|
||||
type nonRetriableError struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// Error returns the error message.
|
||||
func (e *nonRetriableError) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the wrapped error.
|
||||
func (e *nonRetriableError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue