Improve tsh debug messages with client version output#60297
Conversation
| // print tsh version when --debug flag is set | ||
| // to diagnose potential client version mismatch | ||
| if cf.Debug && command != ver.FullCommand() { | ||
| modules.GetModules().PrintVersion() |
There was a problem hiding this comment.
This prints to stdout, but on macOS tsh can be configured to log to os_log.
Instead of logging the version to stdout, I think a better approach might be to make sure that initLogger was already called twice (it was at this point in the Run function) and use logger.DebugContext instead of printing to stdout. This will make the logger print to whatever destination it is set, in case we add more destinations in the future.
This would require extending modules with something like GetVersionString. It unfortunately complicates the whole implementation, as adjusting the Modules interface means that you first have to add the relevant method to the enterprise Modules in the other repo, then update the e ref in the OSS repo and only then merge the OSS change which uses the new method. Otherwise merging just the OSS change would end up breaking the enterprise build.
I know it's much more complicated than what you initially wanted to do here. But I think it'll also be a good introduction to the peculiarities of the enterprise repo and how to work with it. :~)
There was a problem hiding this comment.
I think it'd also be fine to merge this first and then make it use the logger in another PR!
There was a problem hiding this comment.
I think we should log directly instead of using the modules function to print the version here.
That aligns better with what we already do in tbot, see #58033.
| // print tsh version when --debug flag is set | ||
| // to diagnose potential client version mismatch | ||
| if cf.Debug && command != ver.FullCommand() { | ||
| modules.GetModules().PrintVersion() |
There was a problem hiding this comment.
I think it'd also be fine to merge this first and then make it use the logger in another PR!
|
Regarding the failed Unit Tests, it looks like it is most likely unrelated to your changes and is the result of a flaky test failure. The error message looks like the same one as seen in #32958. In this case you can re-run the unit tests to pass the check. If the flaky test wasn't already being tracked, it'd also be helpful to create a GitHub issue to track it. |
|
My mistake, after taking a closer look at the error messages, I think the code change may actually be causing this particular test case to fail. So we'll probably need to go with the above suggestions and avoid writing to stdout here. The rsync man page documents this under their Diagnostics section:
|
rosstimothy
left a comment
There was a problem hiding this comment.
Looks good other than one small suggestion. Happy first commit @kshi36 🎉 !
| // print tsh version when --debug flag is set | ||
| // to diagnose potential client version mismatch | ||
| if cf.Debug && command != ver.FullCommand() { | ||
| logger.InfoContext(ctx, "Debugging tsh client", |
There was a problem hiding this comment.
I think we should alter the message to match what tbot uses.
| logger.InfoContext(ctx, "Debugging tsh client", | |
| logger.InfoContext(ctx, "Initializing tsh", |
r0mant
left a comment
There was a problem hiding this comment.
lgtm with one more suggestion
|
|
||
| output, err := exec.Command(testExecutable, "logout", "--debug").CombinedOutput() | ||
| require.NoError(t, err) | ||
| require.Contains(t, string(output), "Initializing tsh version") |
There was a problem hiding this comment.
Nit: Can we check that the output contains versions as well?
* Added client version output when --debug flag is added to tsh commands * Moved client version output to logger * Altered tsh client version output to match tbot's, added test coverage * Updated test to check versions in output
* Added client version output when --debug flag is added to tsh commands * Moved client version output to logger * Altered tsh client version output to match tbot's, added test coverage * Updated test to check versions in output
* Added client version output when --debug flag is added to tsh commands * Moved client version output to logger * Altered tsh client version output to match tbot's, added test coverage * Updated test to check versions in output
* Added client version output when --debug flag is added to tsh commands * Moved client version output to logger * Altered tsh client version output to match tbot's, added test coverage * Updated test to check versions in output Co-authored-by: Kevin <76608931+kshi36@users.noreply.github.com>
* Added client version output when --debug flag is added to tsh commands * Moved client version output to logger * Altered tsh client version output to match tbot's, added test coverage * Updated test to check versions in output
Fixes #55738.
Added tsh client version to improve tsh command debugging, eg. client version mismatch.
Changelog: Updated tsh debug output to include tsh client version when --debug flag is set.