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

cli: add debug_zip_command_flags.txt file in debug zip #129785

Merged

Conversation

aa-joshi
Copy link
Contributor

@aa-joshi aa-joshi commented Aug 28, 2024

Previously, debug zip doesn't have any way of determining the flags set during command execution. It is a pain point for support team to figure out flag values passesd during debug zip generation. To address this, we have added debug_zip_command_flags.txt file in debug zip. It captures flag values set during command execution.

Epic: CRDB-32134
Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@aa-joshi aa-joshi marked this pull request as ready for review August 28, 2024 10:37
@aa-joshi aa-joshi requested review from a team as code owners August 28, 2024 10:37
@aa-joshi aa-joshi requested review from angles-n-daemons and arjunmahishi and removed request for a team August 28, 2024 10:37
Copy link
Contributor

@arjunmahishi arjunmahishi left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @aa-joshi and @angles-n-daemons)


pkg/cli/zip.go line 371 at r1 (raw file):

			s = zr.start("capture debug zip flags")
			if err := z.createJSON(s, zc.prefix+"/debug_zip_command_flags.json", zipCtx); err != nil {

Have you considered reading the provided args from *cobra.Command? it will have all the flags that the user passed. That would significantly reduce the size of the diff.

Copy link
Contributor Author

@aa-joshi aa-joshi left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @angles-n-daemons and @arjunmahishi)


pkg/cli/zip.go line 371 at r1 (raw file):

Previously, arjunmahishi (Arjun Mahishi) wrote…

Have you considered reading the provided args from *cobra.Command? it will have all the flags that the user passed. That would significantly reduce the size of the diff.

Thanks for the suggestion! I did explore that cobra command. The challenge with that is we have to iterate over flags to fetch the value & dump into file.
Coming back to diff, The only change is to export field for generating json file. Most of the files are from test case updates.
I can split test & code changes in different commits.
Let me know your thoughts.

@arjunmahishi
Copy link
Contributor

arjunmahishi commented Aug 28, 2024

pkg/cli/zip.go line 371 at r1 (raw file):

The challenge with that is we have to iterate over flags to fetch the value & dump into file.

Should be pretty straightforward. I think there is a helper function specifically built for this kind of usecase.

cmd.Flags().VisitAll(func(f *pflag.Flag) {
  if f.Changed {
    // this condition is true only if the user has set the flag
    // add to a string builder
  }
})

Other than the diff size, IMO this is a safer change. Sometimes toggling a struct field between exported/un-exported can have unexpected side effects.

Either way, I think it will be good to add a datadriven test that asserts the file generated.

@aa-joshi aa-joshi force-pushed the CRDB-41042_add_command_execution_flags branch from f53d34b to 84d261c Compare August 29, 2024 06:39
@aa-joshi aa-joshi changed the title cli: add debug_zip_command_flags.json file in debug zip cli: add debug_zip_command_flags.txt file in debug zip Aug 29, 2024
@aa-joshi aa-joshi force-pushed the CRDB-41042_add_command_execution_flags branch from 84d261c to 1646471 Compare August 29, 2024 06:57
Previously, debug zip doesn't have any way of determining the flags set during
command execution. It is a pain point for support team to figure out flag
values passesd during debug zip generation. To address this, we have added
`debug_zip_command_flags.txt` file in debug zip. It captures flag values set
during command execution.

Epic: CRDB-32134
Release note: None
@aa-joshi aa-joshi force-pushed the CRDB-41042_add_command_execution_flags branch from 1646471 to 24c42b1 Compare August 29, 2024 07:02
Copy link
Contributor Author

@aa-joshi aa-joshi left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @angles-n-daemons and @arjunmahishi)


pkg/cli/zip.go line 371 at r1 (raw file):

Previously, arjunmahishi (Arjun Mahishi) wrote…

The challenge with that is we have to iterate over flags to fetch the value & dump into file.

Should be pretty straightforward. I think there is a helper function specifically built for this kind of usecase.

cmd.Flags().VisitAll(func(f *pflag.Flag) {
  if f.Changed {
    // this condition is true only if the user has set the flag
    // add to a string builder
  }
})

Other than the diff size, IMO this is a safer change. Sometime toggling a struct field between exporter/un-exported can have unexpected side effects.

Either way, I think it will be good to add a datadriven test that asserts the file generated.

Suggested changes are updated in latest commit. PTAL. TIA.

@aa-joshi aa-joshi requested a review from arjunmahishi August 29, 2024 09:04
Copy link
Contributor

@arjunmahishi arjunmahishi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @aa-joshi and @angles-n-daemons)


pkg/cli/zip.go line 336 at r2 (raw file):

			// the profiles.
			{
				s := zc.clusterPrinter.start("pprof summary script")

Last question: Was this an intentional change? Removing the : (increasing the scope of s)

Copy link
Contributor Author

@aa-joshi aa-joshi left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @angles-n-daemons and @arjunmahishi)


pkg/cli/zip.go line 336 at r2 (raw file):

Previously, arjunmahishi (Arjun Mahishi) wrote…

Last question: Was this an intentional change? Removing the : (increasing the scope of s)

Yes, it is intentional. nogo was throwing error due to re initialisation of s.

@aa-joshi
Copy link
Contributor Author

aa-joshi commented Sep 2, 2024

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 2, 2024

Build failed:

@celiala
Copy link
Collaborator

celiala commented Sep 6, 2024

Build failed:

unit_tests passed on re-try.

bors r+

@craig craig bot merged commit f3519c0 into cockroachdb:master Sep 6, 2024
23 checks passed
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.

4 participants