-
Notifications
You must be signed in to change notification settings - Fork 71
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
Testing: Use simpler logger types #1501
Conversation
@@ -3898,12 +3907,11 @@ func installGolang(ctx context.Context, logger *logging.DirectoryLogger, vm *gce | |||
Start-Process msiexec.exe -ArgumentList "/i","golang.msi","/quiet" -Wait `, goVersion, goArch) | |||
} else { | |||
installCmd = fmt.Sprintf(` | |||
set -e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this set -e is superfluous when the script is only one line long, and it's also superfluous when using RunRemotely. so I got rid of it.
gsutil cp \ | ||
"gs://stackdriver-test-143416-go-install/go%s.linux-%s.tar.gz" - | \ | ||
tar --directory /usr/local -xzf /dev/stdin`, goVersion, goArch) | ||
sudo tar --directory /usr/local -xzf /dev/stdin`, goVersion, goArch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RunScriptRemotely runs with "sudo" while RunRemotely does not, so I had to stick a sudo on here.
Description
The goal of this PR was to make
gce.RunScriptRemotely
more user-friendly by replacing itslogging.DirectoryLogger
argument with a plainerlog.Logger
argument. This removes the requirement that all transitive callsites to this function (of which there are a lot) pass around alogging.DirectoryLogger
, allowing them to skip A LOT of calls to.ToMainLog()
all over the place. [fun fact:ops_agent_test.go
is more than 1% smaller due to this PR.] In addition to being cleaner to look at, it's also better to decide which log file to write to in a small number of places, instead of having every single callsite to the logger make the decision separately to write to the main log.For some perspective, there were 170 calls to
.ToMainLog()
inops_agent_test
before this PR, and only 3 calls to.ToFile()
, indicating that the vast majority of the time, just using the main log is fine. [And if we wanted to, I could argue that the remaining 3 calls are also unnecessary with some tweaks, but that's not a concern for me here.]This PR is in the spirit of #1238, in which I realized that sometimes it's inconvenient to pass around a
DirectoryLogger
and started the process of limiting its use to the (few) places that actually need it.A downside (?) to this PR is that a small amount of "noise" that was previously stowed away in
file_uploads.txt
for Windows tests is now going to appear in the main log. However, it's really not a lot of noise. For a single call toRunScriptRemotely
, we'll have this much additional text in main_log.txt:And the last line of this noise won't be printed anyway unless there are errors (after this PR, see minor change to
gce_testing.go
).After this PR, there is only one dependency of
gce_testing.go
onDirectoryLogger
, and that is justgce.SetupLogger()
, which could be moved into thelogging
package (in some future PR).Related issue
no bug, cleanup
How has this been tested?
Automated tests only
Checklist: