Skip to content

Commit

Permalink
Merge #136740
Browse files Browse the repository at this point in the history
136740: backup: remove enterprise checks r=dt a=dt

Release note: none.
Epic: none.

Co-authored-by: David Taylor <[email protected]>
  • Loading branch information
craig[bot] and dt committed Dec 9, 2024
2 parents dec11f5 + 163a7be commit c651d65
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 92 deletions.
2 changes: 0 additions & 2 deletions pkg/backup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ go_library(
"//pkg/ccl/kvccl/kvfollowerreadsccl",
"//pkg/ccl/multiregionccl",
"//pkg/ccl/storageccl",
"//pkg/ccl/utilccl",
"//pkg/cloud",
"//pkg/cloud/cloudcheck",
"//pkg/cloud/cloudpb",
Expand Down Expand Up @@ -221,7 +220,6 @@ go_test(
"//pkg/base",
"//pkg/blobs",
"//pkg/build/bazel",
"//pkg/ccl",
"//pkg/ccl/kvccl",
"//pkg/ccl/multiregionccl",
"//pkg/ccl/multiregionccl/multiregionccltestutils",
Expand Down
15 changes: 0 additions & 15 deletions pkg/backup/alter_backup_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strconv"

"github.com/cockroachdb/cockroach/pkg/backup/backuppb"
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl"
"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
"github.com/cockroachdb/cockroach/pkg/scheduledjobs/schedulebase"
Expand Down Expand Up @@ -144,7 +143,6 @@ func doAlterBackupSchedules(
p,
spec.fullBackupAlways,
spec.fullBackupRecurrence,
spec.isEnterpriseUser,
s,
); err != nil {
return err
Expand Down Expand Up @@ -418,7 +416,6 @@ func processFullBackupRecurrence(
p sql.PlanHookState,
fullBackupAlways bool,
fullBackupRecurrence string,
isEnterpriseUser bool,
s scheduleDetails,
) (scheduleDetails, error) {
var err error
Expand Down Expand Up @@ -449,12 +446,6 @@ func processFullBackupRecurrence(
return s, nil
}

// We have FULL BACKUP <cron>.
if !isEnterpriseUser {
return scheduleDetails{}, errors.Newf("Enterprise license required to use incremental backups. " +
"To modify the cadence of a full backup, use the 'RECURRING <cron>' clause instead.")
}

if s.incJob == nil {
// No existing incremental job, so we need to create it, copying details
// from the full.
Expand Down Expand Up @@ -628,7 +619,6 @@ type alterBackupScheduleSpec struct {
recurrence string
fullBackupRecurrence string
fullBackupAlways bool
isEnterpriseUser bool
label string
into []string
backupOptions tree.BackupOptions
Expand Down Expand Up @@ -712,11 +702,6 @@ func makeAlterBackupScheduleSpec(
return nil, err
}

enterpriseCheckErr := utilccl.CheckEnterpriseEnabled(
p.ExecCfg().Settings,
"BACKUP INTO LATEST")
spec.isEnterpriseUser = enterpriseCheckErr == nil

return spec, nil
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/backup/backup_intents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/ccl"
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
"github.com/cockroachdb/cockroach/pkg/testutils"
Expand All @@ -29,7 +28,6 @@ import (
func TestCleanupIntentsDuringBackupPerformanceRegression(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
defer ccl.TestingEnableEnterprise()()

skip.UnderRace(t, "measures backup times to ensure intent resolution does not regress, can't work under race")
skip.UnderDeadlock(t, "measures backup times to ensure intent resolution does not regress, can't work under deadlock")
Expand Down
9 changes: 1 addition & 8 deletions pkg/backup/backup_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/backup/backuputils"
"github.com/cockroachdb/cockroach/pkg/build"
"github.com/cockroachdb/cockroach/pkg/ccl/kvccl/kvfollowerreadsccl"
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl"
"github.com/cockroachdb/cockroach/pkg/cloud"
"github.com/cockroachdb/cockroach/pkg/cloud/cloudpb"
"github.com/cockroachdb/cockroach/pkg/clusterversion"
Expand Down Expand Up @@ -773,10 +772,7 @@ func (b *backupResumer) Resume(ctx context.Context, execCtx interface{}) error {
}

// Collect telemetry, once per backup after resolving its destination.
lic := utilccl.CheckEnterpriseEnabled(
p.ExecCfg().Settings, "",
) != nil
collectTelemetry(ctx, backupManifest, initialDetails, details, lic, b.job.ID())
collectTelemetry(ctx, backupManifest, initialDetails, details, true, b.job.ID())
}

// For all backups, partitioned or not, the main BACKUP manifest is stored at
Expand Down Expand Up @@ -1795,9 +1791,6 @@ func getBackupDetailAndManifest(
return jobspb.BackupDetails{}, backuppb.BackupManifest{}, errors.Errorf("cannot append a backup of specific tables or databases to a cluster backup")
}

if err := requireEnterprise(execCfg, "incremental"); err != nil {
return jobspb.BackupDetails{}, backuppb.BackupManifest{}, err
}
lastEndTime := prevBackups[len(prevBackups)-1].EndTime
if lastEndTime.Compare(initialDetails.EndTime) > 0 {
return jobspb.BackupDetails{}, backuppb.BackupManifest{},
Expand Down
35 changes: 0 additions & 35 deletions pkg/backup/backup_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/cockroachdb/cockroach/pkg/backup/backupbase"
"github.com/cockroachdb/cockroach/pkg/backup/backupresolver"
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl"
"github.com/cockroachdb/cockroach/pkg/cloud"
"github.com/cockroachdb/cockroach/pkg/cloud/cloudprivilege"
"github.com/cockroachdb/cockroach/pkg/featureflag"
Expand Down Expand Up @@ -366,16 +365,6 @@ func checkPrivilegesForBackup(
return cloudprivilege.CheckDestinationPrivileges(ctx, p, to)
}

func requireEnterprise(execCfg *sql.ExecutorConfig, feature string) error {
if err := utilccl.CheckEnterpriseEnabled(
execCfg.Settings,
fmt.Sprintf("BACKUP with %s", feature),
); err != nil {
return err
}
return nil
}

func backupTypeCheck(
ctx context.Context, stmt tree.Statement, p sql.PlanHookState,
) (matched bool, header colinfo.ResultColumns, _ error) {
Expand Down Expand Up @@ -536,12 +525,6 @@ func backupPlanHook(
return errors.Errorf("BACKUP cannot be used inside a multi-statement transaction without DETACHED option")
}

if len(to) > 1 {
if err := requireEnterprise(p.ExecCfg(), "partitioned destinations"); err != nil {
return err
}
}

if len(incrementalStorage) > 0 && (len(incrementalStorage) != len(to)) {
return errors.New("the incremental_location option must contain the same number of locality" +
" aware URIs as the full backup destination")
Expand All @@ -564,27 +547,9 @@ func backupPlanHook(

switch encryptionParams.Mode {
case jobspb.EncryptionMode_Passphrase:
if err := requireEnterprise(p.ExecCfg(), "encryption"); err != nil {
return err
}
encryptionParams.RawPassphrase = pw
case jobspb.EncryptionMode_KMS:
encryptionParams.RawKmsUris = kms
if err := requireEnterprise(p.ExecCfg(), "encryption"); err != nil {
return err
}
}

if revisionHistory {
if err := requireEnterprise(p.ExecCfg(), "revision_history"); err != nil {
return err
}
}

if executionLocality.NonEmpty() {
if err := requireEnterprise(p.ExecCfg(), "execution locality"); err != nil {
return err
}
}

var targetDescs []catalog.Descriptor
Expand Down
1 change: 0 additions & 1 deletion pkg/backup/backupresolver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ go_test(
],
embed = [":backupresolver"],
deps = [
"//pkg/ccl",
"//pkg/ccl/storageccl",
"//pkg/keys",
"//pkg/security/securityassets",
Expand Down
2 changes: 0 additions & 2 deletions pkg/backup/backupresolver/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach/pkg/ccl"
_ "github.com/cockroachdb/cockroach/pkg/ccl/storageccl"
"github.com/cockroachdb/cockroach/pkg/security/securityassets"
"github.com/cockroachdb/cockroach/pkg/security/securitytest"
Expand All @@ -20,7 +19,6 @@ import (
)

func TestMain(m *testing.M) {
defer ccl.TestingEnableEnterprise()()
securityassets.SetLoader(securitytest.EmbeddedAssets)
randutil.SeedForTests()
serverutils.InitTestServerFactory(server.TestServerFactory)
Expand Down
27 changes: 2 additions & 25 deletions pkg/backup/create_scheduled_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/cockroachdb/cockroach/pkg/backup/backupdest"
"github.com/cockroachdb/cockroach/pkg/backup/backuppb"
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl"
"github.com/cockroachdb/cockroach/pkg/cloud"
"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/jobs"
Expand Down Expand Up @@ -70,8 +69,6 @@ var scheduledBackupGCProtectionEnabled = settings.RegisterBoolSetting(
type scheduledBackupSpec struct {
*tree.ScheduledBackup

isEnterpriseUser bool

// Schedule specific properties that get evaluated.
scheduleLabel *string
recurrence *string
Expand Down Expand Up @@ -379,7 +376,7 @@ func doCreateBackupSchedules(

if firstRun != nil {
full.SetNextRun(*firstRun)
} else if eval.isEnterpriseUser && fullRecurrencePicked {
} else if fullRecurrencePicked {
// The enterprise user did not indicate preference when to run full backups,
// and we picked the schedule ourselves.
// Run full backup immediately so that we do not wind up waiting for a long
Expand Down Expand Up @@ -623,12 +620,7 @@ func makeScheduledBackupSpec(
spec.recurrence = &rec
}

enterpriseCheckErr := utilccl.CheckEnterpriseEnabled(
p.ExecCfg().Settings,
"BACKUP INTO LATEST")
spec.isEnterpriseUser = enterpriseCheckErr == nil

if spec.isEnterpriseUser && schedule.FullBackup != nil {
if schedule.FullBackup != nil {
if schedule.FullBackup.AlwaysFull {
spec.fullBackupRecurrence = spec.recurrence
spec.recurrence = nil
Expand All @@ -639,21 +631,6 @@ func makeScheduledBackupSpec(
}
spec.fullBackupRecurrence = &rec
}
} else if !spec.isEnterpriseUser {
if schedule.FullBackup == nil || schedule.FullBackup.AlwaysFull {
// All backups are full cluster backups for free users.
spec.fullBackupRecurrence = spec.recurrence
spec.recurrence = nil
if schedule.FullBackup == nil {
p.BufferClientNotice(ctx,
pgnotice.Newf("Without an enterprise license,"+
" this schedule will only run full backups. To mute this notice, "+
"add the 'FULL BACKUP ALWAYS' clause to your CREATE SCHEDULE command."))
}
} else {
// Cannot use incremental backup w/out enterprise license.
return nil, enterpriseCheckErr
}
}

spec.scheduleOpts, err = exprEval.KVOptions(
Expand Down
2 changes: 0 additions & 2 deletions pkg/backup/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"os"
"testing"

"github.com/cockroachdb/cockroach/pkg/ccl"
_ "github.com/cockroachdb/cockroach/pkg/ccl/storageccl"
"github.com/cockroachdb/cockroach/pkg/security/securityassets"
"github.com/cockroachdb/cockroach/pkg/security/securitytest"
Expand All @@ -20,7 +19,6 @@ import (
)

func TestMain(m *testing.M) {
defer ccl.TestingEnableEnterprise()()
securityassets.SetLoader(securitytest.EmbeddedAssets)
randutil.SeedForTests()
serverutils.InitTestServerFactory(server.TestServerFactory)
Expand Down

0 comments on commit c651d65

Please sign in to comment.