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

upgrades: delete V22_2SystemPrivilegesTable upgrade and version gates #93281

Merged
merged 1 commit into from
Dec 15, 2022

Conversation

andyyang890
Copy link
Collaborator

@andyyang890 andyyang890 commented Dec 8, 2022

This patch deletes the V22_2SystemPrivilegesTable upgrade since its
associated unit test starts to fail when the bootstrap schema for the
system.privileges table is updated. This is safe to do since the
release engineering team has previously stated they will bump
binaryMinSupportedVersion before cutting the branch for 23.1.

Epic: None

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch 2 times, most recently from d3e3026 to 014aba6 Compare December 9, 2022 18:44
@andyyang890 andyyang890 changed the title upgrades: delete V22_2SystemPrivilegesTable upgrade upgrades: delete V22_2SystemPrivilegesTable upgrade and version gates Dec 9, 2022
@andyyang890 andyyang890 marked this pull request as ready for review December 9, 2022 20:55
@andyyang890 andyyang890 requested a review from a team December 9, 2022 20:55
@andyyang890 andyyang890 requested a review from a team as a code owner December 9, 2022 20:55
@andyyang890 andyyang890 requested a review from a team December 9, 2022 20:55
@andyyang890 andyyang890 requested a review from a team as a code owner December 9, 2022 20:55
@andyyang890 andyyang890 requested review from a team, rhu713, rafiss and dt and removed request for a team December 9, 2022 20:55
@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from 014aba6 to d03d78a Compare December 12, 2022 21:12
ecwall
ecwall previously requested changes Dec 12, 2022
Copy link
Contributor

@ecwall ecwall 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 @andyyang890, @dt, @rafiss, and @rhu713)


pkg/ccl/backupccl/restore_planning.go line 1236 at r1 (raw file):

		) == nil

		if requiresRestoreSystemPrivilege && hasRestoreSystemPrivilege {

This isn't the part you changed, but this conditional seems kind of strange. I think it is easier to read as this to be more consistent with other code

if requiresRestoreSystemPrivilege {
  if err := p.CheckPrivilegeForUser(
    ctx, syntheticprivilege.GlobalPrivilegeObject, privilege.RESTORE, p.User()
  ); err != nil {
    return pgerror.Newf(pgcode.InsufficientPrivilege,
      "only users with the admin role or the RESTORE system privilege are allowed to perform"+
      " a cluster restore")
  }
  return checkRestoreDestinationPrivileges(ctx, p, from)
}

pkg/ccl/backupccl/restore_planning.go line 1258 at r1 (raw file):

	}

	if hasRestoreSystemPrivilege {

hasRestoreSystemPrivilege isn't used anywhere else so return checkRestoreDestinationPrivileges(ctx, p, from) can be moved into if len(restoreStmt.Targets.Databases) > 0 { ... }.

@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from d03d78a to 57841ab Compare December 13, 2022 07:51
Copy link
Collaborator Author

@andyyang890 andyyang890 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 @dt, @ecwall, @rafiss, and @rhu713)


pkg/ccl/backupccl/restore_planning.go line 1236 at r1 (raw file):

Previously, ecwall (Evan Wall) wrote…

This isn't the part you changed, but this conditional seems kind of strange. I think it is easier to read as this to be more consistent with other code

if requiresRestoreSystemPrivilege {
  if err := p.CheckPrivilegeForUser(
    ctx, syntheticprivilege.GlobalPrivilegeObject, privilege.RESTORE, p.User()
  ); err != nil {
    return pgerror.Newf(pgcode.InsufficientPrivilege,
      "only users with the admin role or the RESTORE system privilege are allowed to perform"+
      " a cluster restore")
  }
  return checkRestoreDestinationPrivileges(ctx, p, from)
}

Done.


pkg/ccl/backupccl/restore_planning.go line 1258 at r1 (raw file):

Previously, ecwall (Evan Wall) wrote…

hasRestoreSystemPrivilege isn't used anywhere else so return checkRestoreDestinationPrivileges(ctx, p, from) can be moved into if len(restoreStmt.Targets.Databases) > 0 { ... }.

Done.

@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from 57841ab to 3a59e57 Compare December 13, 2022 16:39
@andyyang890 andyyang890 requested a review from ecwall December 13, 2022 16:39
Copy link
Collaborator

@rafiss rafiss 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 @andyyang890, @dt, @ecwall, and @rhu713)


pkg/ccl/backupccl/backup_planning.go line 391 at r2 (raw file):

		if requiresBackupSystemPrivilege {
			if p.CheckPrivilegeForUser(

nit: this part should be

			if err := p.CheckPrivilegeForUser(
				ctx, syntheticprivilege.GlobalPrivilegeObject, privilege.BACKUP, p.User(),
			); err != nil {
				return pgerror.Wrapf(
					err,
					pgcode.InsufficientPrivilege,
					"only users with the admin role or the BACKUP system privilege are allowed to perform full cluster backups")
			}

pkg/ccl/backupccl/restore_planning.go line 1236 at r2 (raw file):

				ctx, syntheticprivilege.GlobalPrivilegeObject, privilege.RESTORE, p.User(),
			); err != nil {
				return pgerror.Newf(pgcode.InsufficientPrivilege,

nit: use pgerror.Wrapf


pkg/ccl/backupccl/restore_planning.go line 1251 at r2 (raw file):

	// options.
	if len(restoreStmt.Targets.Databases) > 0 &&
		p.CheckPrivilegeForUser(ctx, syntheticprivilege.GlobalPrivilegeObject, privilege.RESTORE, p.User()) == nil {

hm, we don't need to return the error here if it fails? perhaps check with the DR team


pkg/sql/syntheticprivilege/README.md line 345 at r2 (raw file):

				return err
			}
			if !hasModify && !hasView {

thanks for keeping the README up to date!

@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from 3a59e57 to 1404660 Compare December 13, 2022 16:59
Copy link
Collaborator Author

@andyyang890 andyyang890 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 @dt, @ecwall, @rafiss, and @rhu713)


pkg/ccl/backupccl/backup_planning.go line 391 at r2 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

nit: this part should be

			if err := p.CheckPrivilegeForUser(
				ctx, syntheticprivilege.GlobalPrivilegeObject, privilege.BACKUP, p.User(),
			); err != nil {
				return pgerror.Wrapf(
					err,
					pgcode.InsufficientPrivilege,
					"only users with the admin role or the BACKUP system privilege are allowed to perform full cluster backups")
			}

Done.


pkg/ccl/backupccl/restore_planning.go line 1236 at r2 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

nit: use pgerror.Wrapf

Done.


pkg/ccl/backupccl/restore_planning.go line 1251 at r2 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

hm, we don't need to return the error here if it fails? perhaps check with the DR team

Ok, will do.

@dhartunian dhartunian removed the request for review from a team December 13, 2022 20:39
@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from 1404660 to ec36f6d Compare December 14, 2022 03:14
Copy link
Collaborator Author

@andyyang890 andyyang890 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 @dt, @ecwall, @rafiss, and @rhu713)


pkg/ccl/backupccl/restore_planning.go line 1251 at r2 (raw file):

Previously, andyyang890 (Andy Yang) wrote…

Ok, will do.

Talked to DR team on Slack and they're okay with filing an issue to fix that later. See #93630.

@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from ec36f6d to eb4156e Compare December 14, 2022 21:27
@andyyang890
Copy link
Collaborator Author

Hmmm something weird happened with the latest rebase, need to fix it before it's ready for review again

@andyyang890 andyyang890 marked this pull request as draft December 14, 2022 21:30
@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from eb4156e to d8b9040 Compare December 14, 2022 21:40
@andyyang890 andyyang890 marked this pull request as ready for review December 14, 2022 21:41
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

thanks!

Reviewed 14 of 21 files at r1, 1 of 2 files at r3, 5 of 6 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andyyang890, @dt, @ecwall, and @rhu713)

@andyyang890 andyyang890 dismissed ecwall’s stale review December 14, 2022 21:47

Requested changes made

@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from d8b9040 to a4cb0d5 Compare December 14, 2022 22:37
This patch deletes the `V22_2SystemPrivilegesTable` upgrade since its
associated unit test starts to fail when the bootstrap schema for the
`system.privileges` table is updated. This is safe to do since the
release engineering team has previously stated they will bump
`binaryMinSupportedVersion` before cutting the branch for 23.1.

Release note: None
@andyyang890 andyyang890 force-pushed the delete_privileges_migration branch from a4cb0d5 to c636918 Compare December 14, 2022 22:44
@andyyang890
Copy link
Collaborator Author

TFTR!

bors r=rafiss

@craig
Copy link
Contributor

craig bot commented Dec 15, 2022

Build succeeded:

@craig craig bot merged commit 9c8ac7b into cockroachdb:master Dec 15, 2022
@andyyang890 andyyang890 deleted the delete_privileges_migration branch December 15, 2022 02:59
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