Incorrect comparison of volume types with same encryption in cinder.volume.volume_types_encryption_changed()

Bug #1700741 reported by Vivek Soni
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Vivek Soni

Bug Description

def volume_types_encryption_changed(context, vol_type_id1, vol_type_id2):
    """Return whether encryptions of two volume types are same."""
    def _get_encryption(enc):
        enc = dict(enc)
        for param in ENCRYPTION_IGNORED_FIELDS:
            enc.pop(param, None)
        return enc

    enc1 = get_volume_type_encryption(context, vol_type_id1)
    enc2 = get_volume_type_encryption(context, vol_type_id2)

    enc1_filtered = _get_encryption(enc1) if enc1 else None
    enc2_filtered = _get_encryption(enc2) if enc2 else None
    return enc1_filtered != enc2_filtered

Values :-
----------------------
enc1_filtered = {'control_location': u'front-end', 'deleted': False, 'encryption_id': u'65e4b4b0-fc7d-47c3-a9b0-aee33f2d8b73', 'key_size': 256, 'provider': u'nova.volume.encryptors.luks.LuksEncryptor', 'cipher': u'aes-xts-plain64'}

enc2_filtered = {'control_location': u'front-end', 'deleted': False, 'encryption_id': u'9b239a29-5b33-4f65-b0bc-da79b3223ca7', 'key_size': 256, 'provider': u'nova.volume.encryptors.luks.LuksEncryptor', 'cipher': u'aes-xts-plain64'}

Issue :-
----------------------
Above code will always return true because 'encryption_id' field will always be unique(primary key in 'encryption' table in 'cinder' database)

Solution :-
----------------------
we need to ignore 'encryption_id' field before comparing dictionary.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/477888

Changed in cinder:
assignee: nobody → Vivek Soni (viveksoni)
status: New → In Progress
Eric Harney (eharney)
Changed in cinder:
milestone: none → pike-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/477888
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=32ea9339ea13c4cd207a7f1ae5b24e82db90061c
Submitter: Jenkins
Branch: master

commit 32ea9339ea13c4cd207a7f1ae5b24e82db90061c
Author: Vivek Soni <email address hidden>
Date: Wed Jun 28 02:54:30 2017 -0700

    Volume type with encryption comparison

    In volume retype with encryption, comparison of
    volume types with same encryption will returns
    true, instead of false because of unique field
    'encryption_id', so ignore this field before
    comparing.

    Change-Id: I065b904bc881324de79ce59afd5bb97a97ea1b85
    Closes-Bug: 1700741

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 11.0.0.0rc1

This issue was fixed in the openstack/cinder 11.0.0.0rc1 release candidate.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.