conditional_update broken in sqlalchemy 1.4

Bug #1928083 reported by Brian Rosmaita
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Critical
Unassigned

Bug Description

Observed in master (xena development) with both 1.4.13 (proposed upper-constraint [0]) and 1.4.15 (most recent sqlalchemy release [1]), using oslo.db===8.6.0
[0] https://review.opendev.org/c/openstack/requirements/+/788339/7/upper-constraints.txt#150
[1] https://www.sqlalchemy.org/blog/2021/05/11/sqlalchemy-1.4.15-released

"ValueError: not enough values to unpack (expected 2, got 1)"
18 of these in current tests.

Think it's coming from here:
  File "/home/brosmait/repos/openstack/cinder/cinder/db/sqlalchemy/api.py", line 7339, in conditional_update
    value = case(value.whens, value.value, value.else_)

example failure:
cinder.tests.unit.api.contrib.test_admin_actions.AdminActionsAttachDetachTest.test_volume_force_detach_raises_db_error

full test output: http://paste.openstack.org/show/805235/

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

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/cinder/+/790796

Changed in cinder:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.opendev.org/c/openstack/cinder/+/790796
Committed: https://opendev.org/openstack/cinder/commit/55046123f4326ae3caf1c241323f30e4882c57cb
Submitter: "Zuul (22348)"
Branch: master

commit 55046123f4326ae3caf1c241323f30e4882c57cb
Author: Gorka Eguileor <email address hidden>
Date: Tue May 11 17:08:30 2021 +0200

    SQLA 1.4: Fix conditional update Case

    There have been changes in the `case` element in SQLAlchemy 1.4 that
    break our conditional updates.

    Previously SQLA's `case` accepted 3 parameters: whens, value, and else_,
    in that order, and we were passing them as positional arguments.

    New SQLA has changed, and now the signature is:

        def __init__(self, *whens, **kw):

    So we can no longer pass them as positional arguments.

    The solution proposed by this patch relies on passing whens as a keyword
    argument, which is deprecated in 1.4, because that's the compatible way
    between the current SQLA version and 1.4.

    Once the minimum version is bumped to 1.4 we can change our code to pass
    - value = case(whens=value.whens,
    + value = case(*value.whens,

    Closes-Bug: #1928083
    Change-Id: Ia5c4d06affc5acd9a4783f217b6c5375afab50ed

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
Chhavi Agarwal (chhagarw) wrote :

This issue is also seen in stable/wallaby release, request to cherrypick the fix in wallaby branch as well

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 19.0.0.0b1

This issue was fixed in the openstack/cinder 19.0.0.0b1 development milestone.

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.