Skip to content

Commit 11ba8f3

Browse files
authored
BR: Support encryption for restored ebs volumes (#48900) (#48936)
close #48899
1 parent 4faffd8 commit 11ba8f3

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

br/pkg/aws/ebs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ func fetchTargetSnapshots(meta *config.EBSBasedBRMeta, specifiedAZ string) map[s
551551
// CreateVolumes create volumes from snapshots
552552
// if err happens in the middle, return half-done result
553553
// returned map: store id -> old volume id -> new volume id
554-
func (e *EC2Session) CreateVolumes(meta *config.EBSBasedBRMeta, volumeType string, iops, throughput int64, targetAZ string) (map[string]string, error) {
554+
func (e *EC2Session) CreateVolumes(meta *config.EBSBasedBRMeta, volumeType string, iops, throughput int64, encrypted bool, targetAZ string) (map[string]string, error) {
555555
template := ec2.CreateVolumeInput{
556556
VolumeType: &volumeType,
557557
}
@@ -561,6 +561,7 @@ func (e *EC2Session) CreateVolumes(meta *config.EBSBasedBRMeta, volumeType strin
561561
if throughput > 0 {
562562
template.SetThroughput(throughput)
563563
}
564+
template.Encrypted = &encrypted
564565

565566
newVolumeIDMap := make(map[string]string)
566567
var mutex sync.Mutex

br/pkg/task/restore.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ type RestoreConfig struct {
203203
VolumeType pconfig.EBSVolumeType `json:"volume-type" toml:"volume-type"`
204204
VolumeIOPS int64 `json:"volume-iops" toml:"volume-iops"`
205205
VolumeThroughput int64 `json:"volume-throughput" toml:"volume-throughput"`
206+
VolumeEncrypted bool `json:"volume-encrypted" toml:"volume-encrypted"`
206207
ProgressFile string `json:"progress-file" toml:"progress-file"`
207208
TargetAZ string `json:"target-az" toml:"target-az"`
208209
UseFSR bool `json:"use-fsr" toml:"use-fsr"`
@@ -353,6 +354,9 @@ func (cfg *RestoreConfig) ParseFromFlags(flags *pflag.FlagSet) error {
353354
if cfg.VolumeThroughput, err = flags.GetInt64(flagVolumeThroughput); err != nil {
354355
return errors.Trace(err)
355356
}
357+
if cfg.VolumeEncrypted, err = flags.GetBool(flagVolumeEncrypted); err != nil {
358+
return errors.Trace(err)
359+
}
356360

357361
cfg.ProgressFile, err = flags.GetString(flagProgressFile)
358362
if err != nil {

br/pkg/task/restore_ebs_meta.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const (
4141
flagVolumeType = "volume-type"
4242
flagVolumeIOPS = "volume-iops"
4343
flagVolumeThroughput = "volume-throughput"
44+
flagVolumeEncrypted = "volume-encrypted"
4445
flagTargetAZ = "target-az"
4546
)
4647

@@ -54,6 +55,7 @@ func DefineRestoreSnapshotFlags(command *cobra.Command) {
5455
command.Flags().String(flagVolumeType, string(config.GP3Volume), "volume type: gp3, io1, io2")
5556
command.Flags().Int64(flagVolumeIOPS, 0, "volume iops(0 means default for that volume type)")
5657
command.Flags().Int64(flagVolumeThroughput, 0, "volume throughout in MiB/s(0 means default for that volume type)")
58+
command.Flags().Bool(flagVolumeEncrypted, false, "whether encryption is enabled for the volume")
5759
command.Flags().String(flagProgressFile, "progress.txt", "the file name of progress file")
5860
command.Flags().String(flagTargetAZ, "", "the target AZ for restored volumes")
5961

@@ -65,6 +67,7 @@ func DefineRestoreSnapshotFlags(command *cobra.Command) {
6567
_ = command.Flags().MarkHidden(flagVolumeType)
6668
_ = command.Flags().MarkHidden(flagVolumeIOPS)
6769
_ = command.Flags().MarkHidden(flagVolumeThroughput)
70+
_ = command.Flags().MarkHidden(flagVolumeEncrypted)
6871
_ = command.Flags().MarkHidden(flagProgressFile)
6972
_ = command.Flags().MarkHidden(flagTargetAZ)
7073
}
@@ -256,7 +259,7 @@ func (h *restoreEBSMetaHelper) restoreVolumes(progress glue.Progress) (map[strin
256259
}
257260

258261
volumeIDMap, err = ec2Session.CreateVolumes(h.metaInfo,
259-
string(h.cfg.VolumeType), h.cfg.VolumeIOPS, h.cfg.VolumeThroughput, h.cfg.TargetAZ)
262+
string(h.cfg.VolumeType), h.cfg.VolumeIOPS, h.cfg.VolumeThroughput, h.cfg.VolumeEncrypted, h.cfg.TargetAZ)
260263
if err != nil {
261264
return nil, 0, errors.Trace(err)
262265
}

0 commit comments

Comments
 (0)