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: fix debug zip with new columns for cluster settings #107104

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

maryliag
Copy link
Contributor

@maryliag maryliag commented Jul 18, 2023

The addition of new columns on cluster_settings view done on #104449 were causing debug zip fails to add the information from that table, since the query used to gather the information was doing a join and not considering the new columns.

This commit updates the query to use the explicit columns, so even if new columns are added it won't be a problem in the future. It also adds tests for all custom querys used to generate the debug zip, so this type of issue would have been caught.

The file crdb_internal.cluster_settings.txt in debug zips was
empty due to this bug on v23.1.5 (only version affected by this bug).

Fixes #107103

Release note (bug fix): Debug zip now are properly showing the information from cluster_settings. The file crdb_internal.cluster_settings.txt in debug zips was
empty due to this bug on v23.1.5 (only version affected by this bug).

@maryliag maryliag requested review from a team and rharding6373 July 18, 2023 19:13
@maryliag maryliag requested a review from a team as a code owner July 18, 2023 19:13
@maryliag maryliag added the backport-23.1.x Flags PRs that need to be backported to 23.1 label Jul 18, 2023
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@michae2 michae2 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 @maryliag and @rharding6373)


pkg/cli/zip_table_registry.go line 221 at r1 (raw file):

	"crdb_internal.cluster_settings": {
		customQueryRedacted: `SELECT variable, value, type, public, description, default_value, origin FROM (
    		SELECT * 

I'm actually more scared of this * than the outer one. I think it would be better to replace both with explicit column names.

@mgartner
Copy link
Collaborator

pkg/cli/zip_table_registry.go line 221 at r1 (raw file):

Previously, michae2 (Michael Erickson) wrote…

I'm actually more scared of this * than the outer one. I think it would be better to replace both with explicit column names.

+1

Also, I think this reads more idiomatically without the unnecessary subquery and extra parens, but up to you:

SELECT variable, value, type, public, description, default_value, origin
FROM crdb_internal.cluster_settings
WHERE type <> 's'
UNION
SELECT variable, '<redacted>' as value, type, public, description, default_value, origin
FROM crdb_internal.cluster_settings g
WHERE type = 's'

@maryliag maryliag force-pushed the fix-debug-cluster-settings branch from 5173754 to 7ffc88f Compare July 18, 2023 19:20
@mgartner
Copy link
Collaborator

pkg/cli/zip_table_registry.go line 221 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

+1

Also, I think this reads more idiomatically without the unnecessary subquery and extra parens, but up to you:

SELECT variable, value, type, public, description, default_value, origin
FROM crdb_internal.cluster_settings
WHERE type <> 's'
UNION
SELECT variable, '<redacted>' as value, type, public, description, default_value, origin
FROM crdb_internal.cluster_settings g
WHERE type = 's'

Another option:

SELECT
  variable,
  CASE WHEN type = 's' THEN '<redacted>' ELSE value END value,
  type,
  public,
  description,
  default_value,
  origin
FROM crdb_internal.cluster_settings

Copy link
Contributor Author

@maryliag maryliag 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 @michae2 and @rharding6373)


pkg/cli/zip_table_registry.go line 221 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

Another option:

SELECT
  variable,
  CASE WHEN type = 's' THEN '<redacted>' ELSE value END value,
  type,
  public,
  description,
  default_value,
  origin
FROM crdb_internal.cluster_settings

duh... I did the fix, then remove just so I could test and check if the test was caughting the error and forgot to move back to the right location

@maryliag maryliag force-pushed the fix-debug-cluster-settings branch from 7ffc88f to a008565 Compare July 18, 2023 19:23
Copy link
Contributor Author

@maryliag maryliag 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 @michae2 and @rharding6373)


pkg/cli/zip_table_registry.go line 221 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

duh... I did the fix, then remove just so I could test and check if the test was caughting the error and forgot to move back to the right location

Fixed

@maryliag maryliag force-pushed the fix-debug-cluster-settings branch from a008565 to 68daa3b Compare July 18, 2023 19:37
Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @maryliag, @michae2, and @rharding6373)


-- commits line 18 at r1:
Can you mention that the crdb_internal.cluster_settings.txt file in debug zips was empty due to this bug, and that it only affects v23.1.5?

@maryliag maryliag force-pushed the fix-debug-cluster-settings branch from 68daa3b to 9d296bf Compare July 18, 2023 19:48
@maryliag maryliag removed the backport-23.1.x Flags PRs that need to be backported to 23.1 label Jul 18, 2023
@maryliag maryliag requested a review from michae2 July 18, 2023 19:49
Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @maryliag, @mgartner, and @rharding6373)


pkg/cli/zip_table_registry.go line 222 at r4 (raw file):

		customQueryRedacted: `SELECT
			variable,
			CASE WHEN type = 's' THEN '<redacted>' ELSE value END value,

Since we're here anyway, I have another request: could we rewrite this item as:

CASE WHEN type = 's' AND value != default_value THEN '<redacted>' ELSE value END value,

@maryliag maryliag force-pushed the fix-debug-cluster-settings branch from 9d296bf to 6a5cb6d Compare July 18, 2023 20:20
The addition of new columns on cluster_settings view done
on cockroachdb#104449 were causing debug zip fails to add the
information from that table, since the query used to
gather the information was doing a join and not considering
the new columns.

This commit updates the query to use the explicit columns,
so even if new columns are added it won't be a problem in the future.
It also adds tests for all custom querys used to generate the
debug zip, so this type of issue would have been caught.

The file `crdb_internal.cluster_settings.txt` in debug zips was
empty due to this bug on v23.1.5 (only version affected by this bug).

Fixes cockroachdb#107103

Release note (bug fix): Debug zip now are properly showing the
information from cluster_settings. The file
`crdb_internal.cluster_settings.txt` in debug zips was
empty due to this bug on v23.1.5 (only version affected by this bug).
@maryliag maryliag force-pushed the fix-debug-cluster-settings branch from 6a5cb6d to be8c5c1 Compare July 18, 2023 20:32
Copy link
Contributor Author

@maryliag maryliag 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 (and 1 stale) (waiting on @mgartner, @michae2, and @rharding6373)


pkg/cli/zip_table_registry.go line 222 at r4 (raw file):

Previously, michae2 (Michael Erickson) wrote…

Since we're here anyway, I have another request: could we rewrite this item as:

CASE WHEN type = 's' AND value != default_value THEN '<redacted>' ELSE value END value,

Done

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @maryliag and @rharding6373)

@maryliag
Copy link
Contributor Author

TFTRs!
bors r+

@craig
Copy link
Contributor

craig bot commented Jul 18, 2023

Build succeeded:

@craig craig bot merged commit 06b5ba7 into cockroachdb:master Jul 18, 2023
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.

cli: cluster settings omitted in debug zip
5 participants