Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move predicate err check earlier, inside RetryWithRelogin #13368

Merged
merged 12 commits into from
Jun 22, 2022

Conversation

kimlisa
Copy link
Contributor

@kimlisa kimlisa commented Jun 10, 2022

fixes #13163

Description

In tsh, the list resources nodes, apps, dbs, and kubes are wrapped in RetryWithRelogin, so before the predicate error reaches the predicate error check, it prompts user to relogin and then shows predicate error.

RetryWithRelogin now aborts the relogin attempt if the error is of type predicate.

@github-actions github-actions bot requested review from alex-kovoy and gzdunek June 10, 2022 00:42
@kimlisa kimlisa requested review from zmb3 and removed request for alex-kovoy and gzdunek June 10, 2022 00:42
@github-actions github-actions bot added the tsh tsh - Teleport's command line tool for logging into nodes running Teleport. label Jun 10, 2022
@kimlisa kimlisa force-pushed the lisa/bug/resource-query-on-error branch from f5bc9f1 to cfe3078 Compare June 10, 2022 00:49
@@ -714,6 +714,10 @@ func RetryWithRelogin(ctx context.Context, tc *TeleportClient, fn func() error)
return nil
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's already a predicate error, why do you have to wrap it in another predicate error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the IsPredicateError looks for keyword in the error to determine if its predicate, then we use a wrapper to add a link to the predicate documentation:

so if this is the error that returned:

failed to parse predicate expression: identifier "la" is not defined

it will get formatted to this:

ERROR: failed to parse predicate expression: identifier "la" is not defined
Check syntax at https://goteleport.com/docs/setup/reference/predicate-language/#resource-filtering

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels to me that RetryWithRelogin shouldn't be concerned with doing special stuff with errors that have nothing to do with auth. 🤔

Is there a single place which could wrap the predicate error before RetryWithRelogin catches it? Then we could change IsErrorResolvableWithRelogin to return false for predicate errors and that would be it.

If that's not possible, then perhaps another solution would be to make IsErrorResolvableWithRelogin return false for predicate errors and then wrap them in specific callsites, as it was done before this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for reviving this thread, I just noticed that this PR was made 2 weeks ago. Still, long term I think it'd be worthwhile to change it at some point. I think we would have to tackle this anyway when adding support for those queries to Connect.

@kimlisa kimlisa enabled auto-merge (squash) June 18, 2022 00:55
@kimlisa kimlisa merged commit 71bc57c into master Jun 22, 2022
@github-actions
Copy link

@kimlisa See the table below for backport results.

Branch Result
branch/v10 Create PR
branch/v9 Failed

@kimlisa kimlisa deleted the lisa/bug/resource-query-on-error branch June 22, 2022 15:22
kimlisa added a commit that referenced this pull request Jun 22, 2022
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.
kimlisa added a commit that referenced this pull request Jun 24, 2022
… (#13747)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid tsh queries force a relogin
4 participants