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

[CRDB-13198] ui, server: update cluster settings to include last update time #78034

Merged
merged 1 commit into from
Mar 29, 2022

Conversation

Santamaura
Copy link
Contributor

@Santamaura Santamaura commented Mar 17, 2022

Resolves #76626

Previously it was difficult to determine from the cluster
settings page which settings have been altered.
This patch updates the cluster settings endpoint to include a
last updated field, indicating when the setting was last altered,
which allows the settings page to include that column in the
table and is pre-sorted by this value.

Release note: None

Release justification: Fairly minor changes for QoL upgrade

Screen Shot 2022-03-21 at 10 42 27 AM

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@Santamaura Santamaura force-pushed the update-cluster-settings branch 3 times, most recently from cefe5b9 to 85d2d19 Compare March 21, 2022 16:38
@Santamaura Santamaura requested review from koorosh and zachlite March 21, 2022 16:44
@Santamaura Santamaura marked this pull request as ready for review March 21, 2022 16:44
@Santamaura Santamaura requested review from a team as code owners March 21, 2022 16:44
if it, err := s.server.sqlServer.internalExecutor.QueryIteratorEx(
ctx, "read-setting", nil, /* txn */
sessiondata.InternalExecutorOverride{User: security.RootUserName()},
"SELECT * FROM system.settings",
Copy link
Contributor

Choose a reason for hiding this comment

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

please specify the column names explicitly. This ensures the code won't break if/when we add more columns to the table or reorder the columns.

if v.LastUpdated != nil {
db := sqlutils.MakeSQLRunner(conn)
q := makeSQLQuery()
q.Append(`SELECT * FROM system.settings WHERE name=$`, k)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

@Santamaura Santamaura force-pushed the update-cluster-settings branch from 85d2d19 to 7e54f67 Compare March 21, 2022 19:15
Copy link
Contributor Author

@Santamaura Santamaura 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 @knz, @koorosh, and @zachlite)


pkg/server/admin.go, line 1760 at r1 (raw file):

Previously, knz (kena) wrote…

please specify the column names explicitly. This ensures the code won't break if/when we add more columns to the table or reorder the columns.

Done.


pkg/server/admin_test.go, line 1126 at r1 (raw file):

Previously, knz (kena) wrote…

ditto.

Done.

@Santamaura Santamaura changed the title ui, server: update cluster settings to include last update time [CRDB-13198] ui, server: update cluster settings to include last update time Mar 22, 2022
Copy link
Collaborator

@dhartunian dhartunian 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 @knz, @koorosh, @Santamaura, and @zachlite)


-- commits, line 16 at r2:
nit: fix release note


pkg/ui/workspaces/db-console/src/views/reports/containers/settings/index.tsx, line 112 at r2 (raw file):

            : "No overrides",
        sort: (setting: IterableSetting) =>
          util.TimestampToMoment(setting.last_updated).valueOf(),

nit: can we precompute the TimestampToMoment so it doesn't happen twice in here?

Copy link
Collaborator

@koorosh koorosh left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 5 files at r1, 1 of 2 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz, @Santamaura, and @zachlite)


pkg/server/admin.go, line 1760 at r2 (raw file):

		ctx, "read-setting", nil, /* txn */
		sessiondata.InternalExecutorOverride{User: security.RootUserName()},
		`SELECT name, "lastUpdated" FROM system.settings`,

User can request specific settings with req.Keys. Can you extend query with condition to retrieve specific settings in this case?

Resolves cockroachdb#76626

Previously it was difficult to determine from the cluster
settings page which settings have been altered.
This patch updates the cluster settings endpoint to include a
last updated field, indicating when the setting was last altered,
which allows the settings page to include that column in the
table and is pre-sorted by this value.

Release justification: Fairly minor changes for QoL upgrade
Release note: None
@Santamaura Santamaura force-pushed the update-cluster-settings branch from 7e54f67 to 2ded655 Compare March 23, 2022 19:11
Copy link
Contributor Author

@Santamaura Santamaura 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 @knz, @koorosh, and @zachlite)


pkg/server/admin.go, line 1760 at r2 (raw file):

Previously, koorosh (Andrii Vorobiov) wrote…

User can request specific settings with req.Keys. Can you extend query with condition to retrieve specific settings in this case?

Hm, it was pointed out to me that in the process of formatting req.Keys for the sql query that using the user input may be a risk for sql injection. I'll leave as is for now but if you know there is a way that is security safe to make this change lmk!


pkg/ui/workspaces/db-console/src/views/reports/containers/settings/index.tsx, line 112 at r2 (raw file):

Previously, dhartunian (David Hartunian) wrote…

nit: can we precompute the TimestampToMoment so it doesn't happen twice in here?

Done.

Copy link
Contributor

@zachlite zachlite left a comment

Choose a reason for hiding this comment

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

:lgtm: nice job.

Reviewed 1 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @knz and @koorosh)

@Santamaura
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 29, 2022

Build succeeded:

@craig craig bot merged commit d5afa87 into cockroachdb:master Mar 29, 2022
@Santamaura Santamaura deleted the update-cluster-settings branch March 29, 2022 18:02
@thtruo
Copy link
Contributor

thtruo commented May 26, 2022

Heads up @Santamaura this change isn't available in v22.1.0 - this might have missed the original release train for 22.1
Can we backport to 22.1 as well as 21.2?

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.

Highlight values that are different from the default in cluster settings
7 participants