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

Further refactoring of magician VCR #11647

Merged
merged 17 commits into from
Sep 26, 2024

Conversation

trodge
Copy link
Contributor

@trodge trodge commented Sep 5, 2024

SA_KEY environment variable now optional, will add support for other credentials in follow-up PR.

Options struct for UploadLogs

logBucket and cassetteBucket moved into Tester object

safeToLog map added, environment variables must be marked as safe to be logged

prNumber parameter for UploadLogs and FetchCassettes is now replaced with opt.Head and head (head includes auto-pr- or auto-cl- prefix)

Release Note Template for Downstream PRs (will be copied)


@trodge trodge requested a review from roaks3 September 5, 2024 20:24
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@trodge trodge marked this pull request as ready for review September 5, 2024 21:58
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@trodge trodge requested review from a team and removed request for roaks3 September 6, 2024 18:15
@trodge trodge marked this pull request as draft September 6, 2024 18:17
@trodge trodge marked this pull request as ready for review September 6, 2024 18:17
@trodge trodge requested review from melinath and removed request for a team September 6, 2024 21:44
Copy link
Member

@melinath melinath left a 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.

.ci/magician/cmd/check_cassettes.go Outdated Show resolved Hide resolved
.ci/magician/cmd/test_terraform_vcr.go Outdated Show resolved Hide resolved
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

Based on the code, I'm not sure these are correct... but I'm also not sure they're being used here? We're not currently using this go file & there could be related bugs there already? attn @iyabchen @shuyama1

Copy link
Contributor Author

@trodge trodge Sep 6, 2024

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.

@@ -100,6 +100,14 @@ func (ar *Runner) ReadFile(name string) (string, error) {
return string(data), nil
}

func (ar *Runner) AppendFile(name, data string) error {
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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 Show resolved Hide resolved
}
}
vt.cassettePaths[version] = cassettePath
if len(fetchErrors) > 0 {
return fmt.Errorf("errors fetching cassettes: %v", fetchErrors)
Copy link
Member

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?

Copy link
Contributor Author

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.

@melinath
Copy link
Member

melinath commented Sep 6, 2024

It could be worth splitting this into multiple smaller PRs.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

1 similar comment
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

1 similar comment
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@roaks3 roaks3 self-requested a review September 13, 2024 18:55
Copy link
Contributor

@roaks3 roaks3 left a 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.

@trodge trodge requested a review from melinath September 13, 2024 19:04
Copy link
Member

@melinath melinath left a 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.)

.ci/magician/cmd/test_terraform_vcr.go Outdated Show resolved Hide resolved
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

trodge and others added 8 commits September 20, 2024 15:06
* 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>
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@trodge trodge requested a review from melinath September 20, 2024 16:13
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (vt *Tester) Run(opts RunOptions) (Result, error) {
func (vt *Tester) Run(opt RunOptions) (Result, error) {

Could this rename be excluded for clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

.ci/magician/vcr/tester.go Show resolved Hide resolved
.ci/magician/vcr/tester.go Show resolved Hide resolved
.ci/magician/cmd/vcr_cassette_update_test.go Outdated Show resolved Hide resolved
.ci/magician/cmd/test_terraform_vcr.go Outdated Show resolved Hide resolved
.ci/magician/cmd/test_terraform_vcr.go Show resolved Hide resolved
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

1 similar comment
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@trodge trodge requested a review from melinath September 25, 2024 17:29
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

Copy link
Member

@melinath melinath left a 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.

Comment on lines 273 to 274
AfterRecording: true,
Parallel: false,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
AfterRecording: true,
Parallel: false,
Parallel: true,

Comment on lines 201 to 202
AfterRecording: false,
Parallel: false,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
AfterRecording: false,
Parallel: false,

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

.ci/magician/cmd/test_terraform_vcr.go Outdated Show resolved Hide resolved
trodge and others added 2 commits September 26, 2024 18:18
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@trodge trodge merged commit 376778b into GoogleCloudPlatform:main Sep 26, 2024
5 checks passed
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

Copy link
Member

@shuyama1 shuyama1 Sep 26, 2024

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.

Copy link
Member

Choose a reason for hiding this comment

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

#11846 fixes this.

sebkalis pushed a commit to sebkalis/magic-modules that referenced this pull request Sep 27, 2024
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
anavada pushed a commit to anavada/magic-modules that referenced this pull request Sep 30, 2024
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
niharika-98 pushed a commit to niharika-98/magic-modules that referenced this pull request Oct 7, 2024
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
trodge added a commit to trodge/magic-modules that referenced this pull request Oct 10, 2024
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Philip-Jonany pushed a commit to Philip-Jonany/magic-modules that referenced this pull request Nov 4, 2024
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants