Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(release/v20.07) fix: Online Restore honors credentials passed in. #6302

Merged
merged 2 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions worker/backup_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,13 @@ type loadFn func(reader io.Reader, groupId uint32, preds predicateSet) (uint64,

// LoadBackup will scan location l for backup files in the given backup series and load them
// sequentially. Returns the maximum Since value on success, otherwise an error.
func LoadBackup(location, backupId string, fn loadFn) LoadResult {
func LoadBackup(location, backupId string, creds *Credentials, fn loadFn) LoadResult {
uri, err := url.Parse(location)
if err != nil {
return LoadResult{0, 0, err}
}

// TODO(martinmr): allow overriding credentials during restore.
h := getHandler(uri.Scheme, nil)
h := getHandler(uri.Scheme, creds)
if h == nil {
return LoadResult{0, 0, errors.Errorf("Unsupported URI: %v", uri)}
}
Expand Down
11 changes: 10 additions & 1 deletion worker/online_restore_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,17 @@ func getEncConfig(req *pb.RestoreRequest) (*viper.Viper, error) {
return config, nil
}

func getCredentialsFromRestoreRequest(req *pb.RestoreRequest) *Credentials {
return &Credentials{
AccessKey: req.AccessKey,
SecretKey: req.SecretKey,
SessionToken: req.SessionToken,
Anonymous: req.Anonymous,
}
}

func writeBackup(ctx context.Context, req *pb.RestoreRequest) error {
res := LoadBackup(req.Location, req.BackupId,
res := LoadBackup(req.Location, req.BackupId, getCredentialsFromRestoreRequest(req),
func(r io.Reader, groupId uint32, preds predicateSet) (uint64, error) {
if groupId != req.GroupId {
// LoadBackup will try to call the backup function for every group.
Expand Down
2 changes: 1 addition & 1 deletion worker/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func RunRestore(pdir, location, backupId string, key x.SensitiveByteSlice) LoadR

// Scan location for backup files and load them. Each file represents a node group,
// and we create a new p dir for each.
return LoadBackup(location, backupId,
return LoadBackup(location, backupId, nil,
func(r io.Reader, groupId uint32, preds predicateSet) (uint64, error) {

dir := filepath.Join(pdir, fmt.Sprintf("p%d", groupId))
Expand Down