Image tasks API excludes in-progress tasks

Bug #1922928 reported by Dan Smith
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
High
Dan Smith
Wallaby
Fix Committed
Undecided
Unassigned
Xena
Fix Released
High
Dan Smith

Bug Description

The glance /images/$uuid/tasks API is excluding in-progress tasks, leading to test failures like this one:

Traceback (most recent call last):
  File "/opt/stack/tempest/tempest/api/image/v2/test_images.py", line 111, in test_image_glance_direct_import
    self.assertEqual(1, len(tasks['tasks']))
  File "/opt/stack/tempest/.tox/tempest/lib/python3.8/site-packages/testtools/testcase.py", line 415, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/opt/stack/tempest/.tox/tempest/lib/python3.8/site-packages/testtools/testcase.py", line 502, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: 1 != 0

This is caused by the fact that we assert that the task is not expired by comparing the expires_at column to the current time. However, if the task is not completed yet, the expires_at will be NULL and never pass that test.

Dan Smith (danms)
Changed in glance:
assignee: nobody → Dan Smith (danms)
Revision history for this message
Abhishek Kekane (abhishek-kekane) wrote :
Changed in glance:
importance: Undecided → High
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/glance 23.0.0.0b2

This issue was fixed in the openstack/glance 23.0.0.0b2 development milestone.

Changed in glance:
status: In Progress → Fix Released
Revision history for this message
Erno Kuvaja (jokke) wrote :

Any idea if this reaches further back than Wallaby?

Revision history for this message
Dan Smith (danms) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (stable/wallaby)

Reviewed: https://review.opendev.org/c/openstack/glance/+/785420
Committed: https://opendev.org/openstack/glance/commit/78e8b7506a7d68089cf08ba24085bf99e070e4ce
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 78e8b7506a7d68089cf08ba24085bf99e070e4ce
Author: Dan Smith <email address hidden>
Date: Wed Apr 7 08:07:05 2021 -0700

    Fix image/tasks API for in-progress tasks

    A slight error in the tasks_get_by_image() DB API method resulted in
    our excluding in-progress tasks from the returned list. This is
    because those tasks have expires_at=NULL, and we were comparing
    the expires_at>=$NOW to find unexpired tasks. This makes us check for
    "NULL or not expired" instead.

    We did have a test asserting the wrong behavior, but it was done to
    increase coverage and thus was asserting the behavior of the code and
    not the *desired* behavior. This fixes that as well.

    Closes-Bug: #1922928
    Change-Id: I1b6971888673b64ef60bed8fbcc97bbcbcf5c2ac
    (cherry picked from commit 2a0d2303c3346b3e771a40c0fe4d4dceaf16f992)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/glance 22.1.0

This issue was fixed in the openstack/glance 22.1.0 release.

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.