rbd: move deletion of DEK to deleteImage()

The ControllerServer should not need to care about support for
encryption, ideally it is transparantly handled by the rbdVolume type
and its internal API.

Deleting the DEK was one of the last remainders that was explicitly done
inside the ControllerServer.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2021-03-24 09:54:57 +01:00 committed by mergify[bot]
parent 151d066938
commit 99da92cfd7
2 changed files with 6 additions and 6 deletions

View File

@ -690,12 +690,6 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
return nil, status.Error(codes.Internal, err.Error())
}
if rbdVol.isEncrypted() {
if err = rbdVol.encryption.RemoveDEK(rbdVol.VolID); err != nil {
util.WarningLog(ctx, "failed to clean the passphrase for volume %s: %s", rbdVol.VolID, err)
}
}
return &csi.DeleteVolumeResponse{}, nil
}

View File

@ -475,6 +475,12 @@ func deleteImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) er
util.DebugLog(ctx, "rbd: delete %s using mon %s, pool %s", image, pOpts.Monitors, pOpts.Pool)
if pOpts.isEncrypted() {
if err = pOpts.encryption.RemoveDEK(pOpts.VolID); err != nil {
util.WarningLog(ctx, "failed to clean the passphrase for volume %s: %s", pOpts.VolID, err)
}
}
err = pOpts.openIoctx()
if err != nil {
return err