Skip to content

Commit

Permalink
refactor(1-1-restore): removed not needed options && src-cluster-id i…
Browse files Browse the repository at this point in the history
…s uuid

This removes 1-1-restore options that are not needed at the moment (we
can added them later if nedded).
Also changed source-cluster-id type to uuid.UUID
  • Loading branch information
VAveryanov8 committed Jan 29, 2025
1 parent 6fd0056 commit 1d5c5e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 110 deletions.
63 changes: 10 additions & 53 deletions pkg/command/one2onerestore/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
"github.com/scylladb/scylla-manager/v3/pkg/command/flag"
"github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/pkg/util/uuid"
"github.com/scylladb/scylla-manager/v3/swagger/gen/scylla-manager/models"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
Expand All @@ -25,20 +26,13 @@ type command struct {
flag.TaskBase
client *managerclient.Client

cluster string
sourceCluster string
location []string
keyspace []string
snapshotTag string
nodesMapping nodesMapping
batchSize int
parallel int
transfers int
rateLimit []string
allowCompaction bool
unpinAgentCPU bool
dryRun bool
showTables bool
cluster string
sourceCluster uuid.Value
location []string
keyspace []string
snapshotTag string
nodesMapping nodesMapping
dryRun bool
}

func NewCommand(client *managerclient.Client) *cobra.Command {
Expand Down Expand Up @@ -83,19 +77,12 @@ func (cmd *command) init() {
w.Keyspace(&cmd.keyspace)

// Flags specific to 1-1-restore
w.Unwrap().StringVarP(&cmd.sourceCluster, "source-cluster-id", "", "", "")
w.Unwrap().Var(&cmd.sourceCluster, "source-cluster-id", "")
w.Unwrap().StringVarP(&cmd.snapshotTag, "snapshot-tag", "T", "", "")
w.Unwrap().Var(&cmd.nodesMapping, "nodes-mapping", "")

// Common configuration for restore procedures
w.Unwrap().IntVar(&cmd.batchSize, "batch-size", 2, "")
w.Unwrap().IntVar(&cmd.parallel, "parallel", 0, "")
w.Unwrap().IntVar(&cmd.transfers, "transfers", 0, "")
w.Unwrap().StringSliceVar(&cmd.rateLimit, "rate-limit", nil, "")
w.Unwrap().BoolVar(&cmd.allowCompaction, "allow-compaction", false, "")
w.Unwrap().BoolVar(&cmd.unpinAgentCPU, "unpin-agent-cpu", false, "")
w.Unwrap().BoolVar(&cmd.dryRun, "dry-run", false, "")
w.Unwrap().BoolVar(&cmd.showTables, "show-tables", false, "")
}

func (cmd *command) run(args []string) error {
Expand Down Expand Up @@ -208,7 +195,7 @@ func flagsToTaskProperties(cmd *command, task *models.Task) (updated bool, err e
},
{
flagName: "source-cluster-id",
value: cmd.sourceCluster,
value: cmd.sourceCluster.String(),
},
{
flagName: "snapshot-tag",
Expand All @@ -218,36 +205,6 @@ func flagsToTaskProperties(cmd *command, task *models.Task) (updated bool, err e
flagName: "nodes-mapping",
value: cmd.nodesMapping,
},
{
flagName: "batch-size",
value: cmd.batchSize,
canBeUpdated: true,
},
{
flagName: "parallel",
value: cmd.parallel,
canBeUpdated: true,
},
{
flagName: "transfers",
value: cmd.transfers,
canBeUpdated: true,
},
{
flagName: "rate-limit",
value: cmd.rateLimit,
canBeUpdated: true,
},
{
flagName: "allow-compaction",
value: cmd.allowCompaction,
canBeUpdated: true,
},
{
flagName: "unpin-agent-cpu",
value: cmd.unpinAgentCPU,
canBeUpdated: true,
},
}

props := task.Properties.(map[string]interface{})
Expand Down
31 changes: 0 additions & 31 deletions pkg/command/one2onerestore/res.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,6 @@ nodes-mapping:
Path to a file with source cluster and target cluster nodes mapping. Each line should contain node mapping in the following format
<source_dc>:<source_rack>:<source_host_id>=<destination_dc>:<destination_rack>:<destination_host_id>

batch-size: |
Number of SSTables per shard to process in one request by one node.
Increasing the default batch size might significantly increase restore performance, as only one shard can work on restoring a single SSTable bundle.
Set to 0 for best performance (batches will contain sstables of total size up to 5% of expected total node workload).
parallel: |
The maximum number of Scylla restore jobs that can be run at the same time (on different SSTables).
Each node can take part in at most one restore at any given moment.
transfers: |
Sets the amount of file transfers to run in parallel when downloading files from backup location to Scylla node.
Set to 0 for the fastest download (results in setting transfers to 2*node_shard_count).
Set to -1 for using the transfers value defined in node's 'scylla-manager-agent.yaml' config file.
rate-limit: |
Limits the download rate (as expressed in megabytes (MiB) per second) at which sstables can be downloaded from backup location to Scylla nodes.
You can set limits for more than one DC using a comma-separated list expressed in the format `[<dc>:]<limit>`.
The <dc>: part is optional and is only needed when different datacenters require different download limits.
Set to 0 for no limit (default 0).
allow-compaction: |
Defines if auto compactions should be running on Scylla nodes during restore.
Disabling auto compactions decreases restore time duration, but increases compaction workload after the restore is done.
unpin-agent-cpu: |
Defines if ScyllaDB Manager Agent should be unpinned from CPUs during restore.
This might significantly improve download speed at the cost of decreasing streaming speed.
dry-run: |
Validates and displays restore information without actually running the restore.
This allows you to display what will happen should the restore run with the parameters you set.
show-tables: |
Prints table names together with keyspace, used in combination with --dry-run.
30 changes: 4 additions & 26 deletions pkg/service/one2onerestore/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,21 @@ package one2onerestore

import (
"github.com/pkg/errors"
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
. "github.com/scylladb/scylla-manager/v3/pkg/service/backup/backupspec"
"github.com/scylladb/scylla-manager/v3/pkg/util/uuid"
)

// Target specifies what data should be restored and from which locations.
type Target struct {
Location []Location `json:"location"`
Keyspace []string `json:"keyspace,omitempty"`
SourceClusterID string `json:"source_cluster_id"`
SourceClusterID uuid.UUID `json:"source_cluster_id"`
SnapshotTag string `json:"snapshot_tag"`
NodesMapping []nodeMapping `json:"nodes_mapping"`
BatchSize int `json:"batch_size,omitempty"`
Parallel int `json:"parallel,omitempty"`
Transfers int `json:"transfers"`
RateLimit []DCLimit `json:"rate_limit,omitempty"`
AllowCompaction bool `json:"allow_compaction,omitempty"`
UnpinAgentCPU bool `json:"unpin_agent_cpu"`
Continue bool `json:"continue"`
}

func defaultTarget() Target {
return Target{
BatchSize: 2,
Parallel: 0,
Transfers: 0,
Continue: true,
}
return Target{}
}

type nodeMapping struct {
Expand All @@ -51,17 +39,7 @@ func (t *Target) validateProperties() error {
if _, err := SnapshotTagTime(t.SnapshotTag); err != nil {
return err
}
if t.BatchSize < 0 {
return errors.New("batch size param has to be greater or equal to zero")
}
if t.Parallel < 0 {
return errors.New("parallel param has to be greater or equal to zero")
}
if t.Transfers != scyllaclient.TransfersFromConfig && t.Transfers != 0 && t.Transfers < 1 {
return errors.New("transfers param has to be equal to -1 (set transfers to the value from scylla-manager-agent.yaml config) " +
"or 0 (set transfers for fastest download) or greater than zero")
}
if t.SourceClusterID == "" {
if t.SourceClusterID.String() == "" {
return errors.New("source cluster id is empty")
}
if len(t.NodesMapping) == 0 {
Expand Down

0 comments on commit 1d5c5e3

Please sign in to comment.