Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
51627: backupccl: make basic BACKUP and RESTORE free to use r=pbardea a=dt

The removes the enterprise license check from RESTORE as well as
from the basic form of BACKUP, making these free to use without
an enterprise licsense.

Advanced BACKUP options like incremental backups, backups to
partitioned storage destinations, or backups that capture
revision history or use file-level encryption all continue
to require an enterprise license, but basic backups can now
be run without a license. RESTORE now never requires a license
regardless of the options passed to it or to the backup it
is restoring.

Release note (enterprise change): Basic BACKUP and RESTORE no longer require an enterprise license.

Co-authored-by: David Taylor <[email protected]>
  • Loading branch information
craig[bot] and dt committed Jul 21, 2020
2 parents c78c517 + d09484e commit f10ba17
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
51 changes: 41 additions & 10 deletions pkg/ccl/backupccl/backup_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ package backupccl

import (
"context"
"fmt"
"net/url"
"sort"

"github.com/cockroachdb/cockroach/pkg/build"
"github.com/cockroachdb/cockroach/pkg/ccl/storageccl"
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl"
"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
"github.com/cockroachdb/cockroach/pkg/jobs/jobsprotectedts"
Expand Down Expand Up @@ -287,12 +287,6 @@ func backupPlanHook(
ctx, span := tracing.ChildSpan(ctx, stmt.StatementTag())
defer tracing.FinishSpan(span)

if err := utilccl.CheckEnterpriseEnabled(
p.ExecCfg().Settings, p.ExecCfg().ClusterID(), p.ExecCfg().Organization(), "BACKUP",
); err != nil {
return err
}

if err := p.RequireAdminRole(ctx, "BACKUP"); err != nil {
return err
}
Expand All @@ -301,13 +295,29 @@ func backupPlanHook(
return errors.Errorf("BACKUP cannot be used inside a transaction without DETACHED option")
}

var isEnterprise bool
requireEnterprise := func(feature string) error {
if isEnterprise {
return nil
}
if err := utilccl.CheckEnterpriseEnabled(
p.ExecCfg().Settings, p.ExecCfg().ClusterID(), p.ExecCfg().Organization(),
fmt.Sprintf("BACKUP with %s", feature),
); err != nil {
return err
}
isEnterprise = true
return nil
}

to, err := toFn()
if err != nil {
return err
}
if len(to) > 1 &&
!p.ExecCfg().Settings.Version.IsActive(ctx, clusterversion.VersionPartitionedBackup) {
return errors.Errorf("partitioned backups can only be made on a cluster that has been fully upgraded to version 19.2")
if len(to) > 1 {
if err := requireEnterprise("partitoned destinations"); err != nil {
return err
}
}

incrementalFrom, err := incrementalFromFn()
Expand All @@ -325,6 +335,9 @@ func backupPlanHook(

mvccFilter := MVCCFilter_Latest
if backupStmt.Options.CaptureRevisionHistory {
if err := requireEnterprise("revision_history"); err != nil {
return err
}
mvccFilter = MVCCFilter_All
}

Expand Down Expand Up @@ -369,6 +382,9 @@ func backupPlanHook(
if err != nil {
return err
}
if err := requireEnterprise("encryption"); err != nil {
return err
}
encryptionPassphrase = []byte(pw)
}

Expand Down Expand Up @@ -508,6 +524,9 @@ func backupPlanHook(
var startTime hlc.Timestamp
var newSpans roachpb.Spans
if len(prevBackups) > 0 {
if err := requireEnterprise("incremental"); err != nil {
return err
}
startTime = prevBackups[len(prevBackups)-1].EndTime
}

Expand Down Expand Up @@ -693,6 +712,18 @@ func backupPlanHook(

collectTelemetry := func() {
telemetry.Count("backup.total.started")
if isEnterprise {
telemetry.Count("backup.licensed")
telemetry.Count("backup.using-enterprise-features")
} else {
if err := utilccl.CheckEnterpriseEnabled(
p.ExecCfg().Settings, p.ExecCfg().ClusterID(), p.ExecCfg().Organization(), "",
); err == nil {
telemetry.Count("backup.licensed")
} else {
telemetry.Count("backup.free")
}
}
if startTime.IsEmpty() {
telemetry.Count("backup.span.full")
} else {
Expand Down
7 changes: 0 additions & 7 deletions pkg/ccl/backupccl/restore_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"sort"

"github.com/cockroachdb/cockroach/pkg/ccl/storageccl"
"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/keys"
Expand Down Expand Up @@ -929,12 +928,6 @@ func restorePlanHook(
ctx, span := tracing.ChildSpan(ctx, stmt.StatementTag())
defer tracing.FinishSpan(span)

if err := utilccl.CheckEnterpriseEnabled(
p.ExecCfg().Settings, p.ExecCfg().ClusterID(), p.ExecCfg().Organization(), "RESTORE",
); err != nil {
return err
}

if err := p.RequireAdminRole(ctx, "RESTORE"); err != nil {
return err
}
Expand Down

0 comments on commit f10ba17

Please sign in to comment.