mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
rbd: copy passphrase for encrypted clones
When a source volume is encrypted, the passphrase needs to be copied and stored for the newly cloned volume. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
7b332a0184
commit
6b1285d38b
@ -1079,6 +1079,29 @@ func (rv *rbdVolume) cloneRbdImageFromSnapshot(ctx context.Context, pSnapOpts *r
|
||||
return fmt.Errorf("failed to create rbd clone: %w", err)
|
||||
}
|
||||
|
||||
// delete the cloned image if a next step fails
|
||||
deleteClone := true
|
||||
defer func() {
|
||||
if deleteClone {
|
||||
err = librbd.RemoveImage(rv.ioctx, rv.RbdImageName)
|
||||
if err != nil {
|
||||
util.ErrorLog(ctx, "failed to delete temporary image %q: %v", rv.String(), err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
if pSnapOpts.isEncrypted() {
|
||||
pSnapOpts.conn = rv.conn.Copy()
|
||||
|
||||
err = pSnapOpts.copyEncryptionConfig(&rv.rbdImage)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to clone encryption config: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Success! Do not delete the cloned image now :)
|
||||
deleteClone = false
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user