fix: improve tsh logs when skipping auto Access Request#22048
Merged
fix: improve tsh logs when skipping auto Access Request#22048
Conversation
Currently the `tsh` debug log is polluted with "errors" created by the [automatic access request feature](https://goteleport.com/docs/access-controls/access-requests/resource-requests/?scope=enterprise#automatically-request-access-for-ssh) even in completely expected scenarios, e.g. when the user has no permission to create Resource Access Requests. Before this change: ``` $ tsh ssh -d alice@one-auth ...<omitted>... 2023-02-17T15:30:16-08:00 DEBU [TSH] unable to request access to node error:[ ERROR REPORT: Original Error: *trace.BadParameterError user attempted a resource request but does not have any "search_as_roles" Stack Trace: github.com/gravitational/teleport/api@v0.0.0/client/client.go:880 github.com/gravitational/teleport/api/client.(*Client).CreateAccessRequest github.com/gravitational/teleport/tool/tsh/tsh.go:2896 main.accessRequestForSSH.func1 github.com/gravitational/teleport/lib/client/api.go:1351 github.com/gravitational/teleport/lib/client.(*TeleportClient).WithRootClusterClient github.com/gravitational/teleport/tool/tsh/tsh.go:2895 main.accessRequestForSSH github.com/gravitational/teleport/tool/tsh/tsh.go:2916 main.retryWithAccessRequest github.com/gravitational/teleport/tool/tsh/tsh.go:2993 main.onSSH github.com/gravitational/teleport/tool/tsh/tsh.go:1086 main.Run github.com/gravitational/teleport/tool/tsh/tsh.go:482 main.main runtime/proc.go:250 runtime.main runtime/asm_amd64.s:1598 runtime.goexit User Message: user attempted a resource request but does not have any "search_as_roles"] tsh/tsh.go:2920 ERROR REPORT: Original Error: *trace.AccessDeniedError access denied to alice connecting to one-auth:0@default@cluster-one Stack Trace: github.com/gravitational/teleport/lib/client/client.go:1633 github.com/gravitational/teleport/lib/client.NewNodeClient github.com/gravitational/teleport/lib/client/client.go:1563 github.com/gravitational/teleport/lib/client.(*ProxyClient).ConnectToNode github.com/gravitational/teleport/lib/client/api.go:1451 github.com/gravitational/teleport/lib/client.(*TeleportClient).ConnectToNode github.com/gravitational/teleport/lib/client/api.go:1525 github.com/gravitational/teleport/lib/client.(*TeleportClient).runShellOrCommandOnSingleNode github.com/gravitational/teleport/lib/client/api.go:1408 github.com/gravitational/teleport/lib/client.(*TeleportClient).SSH github.com/gravitational/teleport/tool/tsh/tsh.go:2995 main.onSSH.func1.1 github.com/gravitational/teleport/lib/client/api.go:504 github.com/gravitational/teleport/lib/client.RetryWithRelogin github.com/gravitational/teleport/tool/tsh/tsh.go:2994 main.onSSH.func1 github.com/gravitational/teleport/tool/tsh/tsh.go:2907 main.retryWithAccessRequest github.com/gravitational/teleport/tool/tsh/tsh.go:2993 main.onSSH github.com/gravitational/teleport/tool/tsh/tsh.go:1086 main.Run github.com/gravitational/teleport/tool/tsh/tsh.go:482 main.main runtime/proc.go:250 runtime.main runtime/asm_amd64.s:1598 runtime.goexit User Message: access denied to alice connecting to one-auth:0@default@cluster-one ``` After: ``` $ tsh ssh -d alice@one-auth ...<omitted>... 2023-02-17T16:42:29-08:00 DEBU [TSH] Not attempting to automatically request access, reason: Resource Access Requests require usable "search_as_roles", none found for user "nklaassen" tsh/tsh.go:2922 ERROR REPORT: Original Error: *trace.AccessDeniedError access denied to alice connecting to one-auth:0@default@cluster-one Stack Trace: github.com/gravitational/teleport/lib/client/client.go:1633 github.com/gravitational/teleport/lib/client.NewNodeClient github.com/gravitational/teleport/lib/client/client.go:1563 github.com/gravitational/teleport/lib/client.(*ProxyClient).ConnectToNode github.com/gravitational/teleport/lib/client/api.go:1451 github.com/gravitational/teleport/lib/client.(*TeleportClient).ConnectToNode github.com/gravitational/teleport/lib/client/api.go:1525 github.com/gravitational/teleport/lib/client.(*TeleportClient).runShellOrCommandOnSingleNode github.com/gravitational/teleport/lib/client/api.go:1408 github.com/gravitational/teleport/lib/client.(*TeleportClient).SSH github.com/gravitational/teleport/tool/tsh/tsh.go:2997 main.onSSH.func1.1 github.com/gravitational/teleport/lib/client/api.go:504 github.com/gravitational/teleport/lib/client.RetryWithRelogin github.com/gravitational/teleport/tool/tsh/tsh.go:2996 main.onSSH.func1 github.com/gravitational/teleport/tool/tsh/tsh.go:2907 main.retryWithAccessRequest github.com/gravitational/teleport/tool/tsh/tsh.go:2995 main.onSSH github.com/gravitational/teleport/tool/tsh/tsh.go:1086 main.Run github.com/gravitational/teleport/tool/tsh/tsh.go:482 main.main runtime/proc.go:250 runtime.main runtime/asm_amd64.s:1598 runtime.goexit User Message: access denied to alice connecting to one-auth:0@default@cluster-one ```
zmb3
approved these changes
Feb 18, 2023
rosstimothy
approved these changes
Feb 18, 2023
|
@nklaassen See the table below for backport results.
|
This was referenced Feb 21, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the
tshdebug log is polluted with "errors" created by the automatic access request feature even in completely expected scenarios, e.g. when the user has no permission to create Resource Access Requests.Before this change:
After:
Resolves #21848