From 737b9b0505130dc38375d41e5930d2ba11ed1173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Wed, 5 Jun 2024 15:06:27 +0200 Subject: [PATCH] feat(restore): don't restore auth and service levels sstables for Scylla 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. --- pkg/service/restore/worker.go | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/pkg/service/restore/worker.go b/pkg/service/restore/worker.go index 5e2b0db14..359458013 100644 --- a/pkg/service/restore/worker.go +++ b/pkg/service/restore/worker.go @@ -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) @@ -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 (