Skip to content

Commit

Permalink
feat(restore): don't restore auth and service levels sstables for Scy…
Browse files Browse the repository at this point in the history
…lla 6.0

Those tables won't exist in Scylla 6.0, but we still should exclude them for a situation when user wants to restore data from backup of older version.
Caused by #3875 and  #3869.
  • Loading branch information
Michal-Leszczynski committed Jun 5, 2024
1 parent 37d3865 commit 737b9b0
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions pkg/service/restore/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ func (w *worker) initTarget(ctx context.Context, properties json.RawMessage) err
"system_distributed.cdc_generation_timestamps",
"*.*_scylla_cdc_log", // All regular CDC tables have "_scylla_cdc_log" suffix
}
if err := IsRestoreAuthAndServiceLevelsFromSStablesSupported(ctx, w.client); err != nil {
w.logger.Info(ctx, "Restore of auth and service levels will be skipped", "error", err)
doNotRestore = append(doNotRestore,
"system_auth",
"system_distributed.service_levels",
)
}

for _, ks := range doNotRestore {
t.Keyspace = append(t.Keyspace, "!"+ks)
Expand Down Expand Up @@ -224,6 +231,45 @@ func IsRestoreSchemaSupported(ctx context.Context, client *scyllaclient.Client)
return nil
}

// ErrRestoreAuthAndServiceLevelsUnsupportedScyllaVersion means that restore auth and service levels procedure is not safe for used Scylla configuration.
var ErrRestoreAuthAndServiceLevelsUnsupportedScyllaVersion = errors.Errorf("restoring authentication and service levels is not supported for given ScyllaDB version")

// IsRestoreAuthAndServiceLevelsFromSStablesSupported checks if restore auth and service levels procedure is supported for used Scylla configuration.
// Because of #3869 and #3875, there is no way fo SM to safely restore auth and service levels into cluster with
// version higher or equal to OSS 6.0 or ENT 2024.2.
func IsRestoreAuthAndServiceLevelsFromSStablesSupported(ctx context.Context, client *scyllaclient.Client) error {
const (
ossConstraint = ">= 6.0, < 2000"
entConstraint = ">= 2024.2, > 1000"
)

status, err := client.Status(ctx)
if err != nil {
return errors.Wrap(err, "get status")
}
for _, n := range status {
ni, err := client.NodeInfo(ctx, n.Addr)
if err != nil {
return errors.Wrapf(err, "get node %s info", n.Addr)
}

oss, err := version.CheckConstraint(ni.ScyllaVersion, ossConstraint)
if err != nil {
return errors.Wrapf(err, "check version constraint for %s", n.Addr)
}
ent, err := version.CheckConstraint(ni.ScyllaVersion, entConstraint)
if err != nil {
return errors.Wrapf(err, "check version constraint for %s", n.Addr)
}

if oss || ent {
return ErrRestoreAuthAndServiceLevelsUnsupportedScyllaVersion
}
}

return nil
}

// initUnits should be called with already initialized target.
func (w *worker) initUnits(ctx context.Context) error {
var (
Expand Down

0 comments on commit 737b9b0

Please sign in to comment.