-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Further refactoring of magician VCR #11647
Conversation
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
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.
a few change requests below. This is a lot of unrelated changes at once so I'm a little concerned I may have missed issues. Please be sure to exercise the VCR test logic (including record after replay) to make sure it's all working as expected.
@@ -90,7 +90,7 @@ var vcrCassetteUpdateCmd = &cobra.Command{ | |||
} | |||
ctlr := source.NewController(env["GOPATH"], "hashicorp", env["GITHUB_TOKEN_CLASSIC"], rnr) | |||
|
|||
vt, err := vcr.NewTester(env, rnr) | |||
vt, err := vcr.NewTester(env, "ci-vcr-logs", "ci-vcr-cassettes", rnr) |
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.
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.
"ci-vcr-cassettes"
was previously hard-coded into the FetchCassettes
function. "ci-vcr-logs"
would only be used if vt.UploadLogs
were called.
I'm making logBucket
an empty string for now since this command uses its own function to upload logs.
.ci/magician/exec/runner.go
Outdated
@@ -100,6 +100,14 @@ func (ar *Runner) ReadFile(name string) (string, error) { | |||
return string(data), nil | |||
} | |||
|
|||
func (ar *Runner) AppendFile(name, data string) error { |
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.
Rather than reading & then writing the file, we may want to use append modes - more efficient: https://pkg.go.dev/os#example-OpenFile-Append
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.
Does this look correct to you?
This function doesn't get called yet, so I'll save testing it for the next PR.
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.
That looks about right; I'm not super familiar with doing this though.
.ci/magician/vcr/tester.go
Outdated
} | ||
} | ||
vt.cassettePaths[version] = cassettePath | ||
if len(fetchErrors) > 0 { | ||
return fmt.Errorf("errors fetching cassettes: %v", fetchErrors) |
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.
I think the changes to the error handling here are incorrect as written. I'm fairly certain the fetches can fail in valid circumstances - for example, if a PR is opened there won't be any cassettes, so the cassettes for that PR will "fail" to be fetched. See https://pantheon.corp.google.com/cloud-build/builds;region=global/fadf17a3-a053-400a-871a-95e1d1b6251f;step=23?inv=1&invt=AbbbyA&project=graphite-docker-images line 12-16 for example.
Why do we need these changes? What would you think about holding them for a later PR?
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.
We don't need to change the error handling now. I'll hold off for a later PR.
It could be worth splitting this into multiple smaller PRs. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
1 similar comment
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
c41b4b4
to
277b088
Compare
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
1 similar comment
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
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.
Generally speaking I don't see anything wrong here, but I would second what Stephen suggested about splitting this up into a few smaller PRs. The difficulty in reading changes like this all together is the context switching that I need to do as I'm reading line-by-line, paired with a things like signature changes, so it is hard for me to feel confident that I haven't missed something. FWIW I think it would save you effort by having each individual review move faster.
That said, pending enough testing that this feels safe, 👍 from me.
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.
Could you split this into multiple PRs?
- one for all the trivial changes like moving the template files
- one per major set of changes (for example, one for changes to make uploadlogs take a struct, one for moving logBucket and cassetteBucket into the tester, one for replacing prnumber with head, etc.)
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
* Reorganize template locations * Add AppendFile method to ExecRunner * Add Head, Version, and LogBucket to template data for templates that use PRNumber
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
.ci/magician/vcr/tester.go
Outdated
@@ -156,34 +194,34 @@ type RunOptions struct { | |||
|
|||
// Run the vcr tests in the given mode and provider version and return the result. | |||
// This will overwrite any existing logs for the given mode and version. | |||
func (vt *Tester) Run(opt RunOptions) (Result, error) { | |||
logPath, err := vt.getLogPath(opt.Mode, opt.Version) | |||
func (vt *Tester) Run(opts RunOptions) (Result, error) { |
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.
func (vt *Tester) Run(opts RunOptions) (Result, error) { | |
func (vt *Tester) Run(opt RunOptions) (Result, error) { |
Could this rename be excluded for clarity?
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.
Done
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
1 similar comment
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
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.
LGTM apart from a couple things that seem incorrect / unnecessary.
AfterRecording: true, | ||
Parallel: false, |
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.
AfterRecording: true, | |
Parallel: false, | |
Parallel: true, |
AfterRecording: false, | ||
Parallel: false, |
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.
AfterRecording: false, | |
Parallel: false, |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR hasn't generated any diffs, but I'll let you know if a future commit does. |
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.
Is this intentional? It might be causing some of the check failures in the main.
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.
#11846 fixes this.
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
SA_KEY
environment variable now optional, will add support for other credentials in follow-up PR.Options struct for
UploadLogs
logBucket
andcassetteBucket
moved into Tester objectsafeToLog
map added, environment variables must be marked as safe to be loggedprNumber
parameter forUploadLogs
andFetchCassettes
is now replaced withopt.Head
andhead
(head
includesauto-pr-
orauto-cl-
prefix)Release Note Template for Downstream PRs (will be copied)