Skip to content

Commit

Permalink
Move predicate err check earlier, inside RetryWithRelogin (#13368)
Browse files Browse the repository at this point in the history
Fixes a bug in tsh ls resources, where users were prompted
to re-login when it was only a predicate query error. 
`RetryWithRelogin` now aborts the re-login attempt if the 
error is of type predicate.
  • Loading branch information
kimlisa authored Jun 22, 2022
1 parent 5a452f1 commit 71bc57c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
4 changes: 4 additions & 0 deletions lib/client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,10 @@ func RetryWithRelogin(ctx context.Context, tc *TeleportClient, fn func() error)
return nil
}

if utils.IsPredicateError(err) {
return trace.Wrap(utils.PredicateError{Err: err})
}

if !IsErrorResolvableWithRelogin(err) {
return trace.Wrap(err)
}
Expand Down
3 changes: 0 additions & 3 deletions tool/tsh/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ func onListDatabases(cf *CLIConf) error {
return trace.Wrap(err)
})
if err != nil {
if utils.IsPredicateError(err) {
return trace.Wrap(utils.PredicateError{Err: err})
}
return trace.Wrap(err)
}

Expand Down
3 changes: 0 additions & 3 deletions tool/tsh/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,9 +963,6 @@ func fetchKubeClusters(ctx context.Context, tc *client.TeleportClient) (teleport
}
return nil
}
if utils.IsPredicateError(err) {
return trace.Wrap(utils.PredicateError{Err: err})
}
return trace.Wrap(err)
}

Expand Down
6 changes: 0 additions & 6 deletions tool/tsh/tsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1646,9 +1646,6 @@ func onListNodes(cf *CLIConf) error {
return err
})
if err != nil {
if utils.IsPredicateError(err) {
return trace.Wrap(utils.PredicateError{Err: err})
}
return trace.Wrap(err)
}
sort.Slice(nodes, func(i, j int) bool {
Expand Down Expand Up @@ -3528,9 +3525,6 @@ func onApps(cf *CLIConf) error {
return err
})
if err != nil {
if utils.IsPredicateError(err) {
return trace.Wrap(utils.PredicateError{Err: err})
}
return trace.Wrap(err)
}

Expand Down

0 comments on commit 71bc57c

Please sign in to comment.