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 committed Jun 22, 2022
1 parent 9f578c8 commit ccf1ad9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
5 changes: 5 additions & 0 deletions lib/client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,11 @@ func RetryWithRelogin(ctx context.Context, tc *TeleportClient, fn func() error)
if !utils.IsHandshakeFailedError(err) && !utils.IsCertExpiredError(err) && !trace.IsBadParameter(err) && !trace.IsTrustError(err) {
return trace.Wrap(err)
}

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

// Don't try to login when using an identity file.
if tc.SkipLocalAuth {
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 @@ -55,9 +55,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 @@ -935,9 +935,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 @@ -1428,9 +1428,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 @@ -3036,9 +3033,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 ccf1ad9

Please sign in to comment.