mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 06:10:22 +00:00
rbd: Handle encryption type default at a more meaningful place
Different places have different meaningful fallback. When parsing from user we should default to block, when parsing stored config we should default to invalid and handle that as an error. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
This commit is contained in:
parent
1fa842277a
commit
a7ea12eb8e
@ -109,7 +109,7 @@ func (ri *rbdImage) isFileEncrypted() bool {
|
||||
}
|
||||
|
||||
func IsFileEncrypted(ctx context.Context, volOptions map[string]string) (bool, error) {
|
||||
_, encType, err := ParseEncryptionOpts(ctx, volOptions)
|
||||
_, encType, err := ParseEncryptionOpts(ctx, volOptions, util.EncryptionTypeInvalid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@ -306,7 +306,7 @@ func (rv *rbdVolume) openEncryptedDevice(ctx context.Context, devicePath string)
|
||||
}
|
||||
|
||||
func (ri *rbdImage) initKMS(ctx context.Context, volOptions, credentials map[string]string) error {
|
||||
kmsID, encType, err := ParseEncryptionOpts(ctx, volOptions)
|
||||
kmsID, encType, err := ParseEncryptionOpts(ctx, volOptions, rbdDefaultEncryptionType)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if kmsID == "" {
|
||||
@ -333,6 +333,7 @@ func (ri *rbdImage) initKMS(ctx context.Context, volOptions, credentials map[str
|
||||
func ParseEncryptionOpts(
|
||||
ctx context.Context,
|
||||
volOptions map[string]string,
|
||||
fallbackEncType util.EncryptionType,
|
||||
) (string, util.EncryptionType, error) {
|
||||
var (
|
||||
err error
|
||||
@ -348,7 +349,7 @@ func ParseEncryptionOpts(
|
||||
return "", util.EncryptionTypeInvalid, err
|
||||
}
|
||||
|
||||
encType := util.FetchEncryptionType(volOptions, rbdDefaultEncryptionType)
|
||||
encType := util.FetchEncryptionType(volOptions, fallbackEncType)
|
||||
|
||||
return kmsID, encType, nil
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ func RegenerateJournal(
|
||||
|
||||
rbdVol.Owner = owner
|
||||
|
||||
kmsID, _, err = ParseEncryptionOpts(ctx, volumeAttributes)
|
||||
kmsID, encryptionType, err = ParseEncryptionOpts(ctx, volumeAttributes, util.EncryptionTypeInvalid)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user