Skip to content

Commit

Permalink
cli: exit set loop early in fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Feb 12, 2024
1 parent a8c0e0b commit 6e0fb83
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cli/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/edgelesssys/nunki/internal/manifest"
"github.com/edgelesssys/nunki/internal/spinner"
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

func newSetCmd() *cobra.Command {
Expand Down Expand Up @@ -178,6 +180,14 @@ func setLoop(
if rpcErr == nil {
return resp, nil
}
grpcSt, ok := status.FromError(rpcErr)
if ok {
switch grpcSt.Code() {
case codes.PermissionDenied, codes.InvalidArgument:
// These errors are not retryable
return nil, rpcErr
}
}
timer := time.NewTimer(1 * time.Second)
select {
case <-ctx.Done():
Expand Down

0 comments on commit 6e0fb83

Please sign in to comment.