Skip to content

Commit 95eaecc

Browse files
committed
cli: exit set loop early in fatal errors
1 parent 61fc7a7 commit 95eaecc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cli/set.go

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"github.com/edgelesssys/nunki/internal/manifest"
1919
"github.com/edgelesssys/nunki/internal/spinner"
2020
"github.com/spf13/cobra"
21+
"google.golang.org/grpc/codes"
22+
"google.golang.org/grpc/status"
2123
)
2224

2325
func newSetCmd() *cobra.Command {
@@ -178,6 +180,14 @@ func setLoop(
178180
if rpcErr == nil {
179181
return resp, nil
180182
}
183+
grpcSt, ok := status.FromError(rpcErr)
184+
if ok {
185+
switch grpcSt.Code() {
186+
case codes.PermissionDenied, codes.InvalidArgument:
187+
// These errors are not retryable
188+
return nil, rpcErr
189+
}
190+
}
181191
timer := time.NewTimer(1 * time.Second)
182192
select {
183193
case <-ctx.Done():

0 commit comments

Comments
 (0)