'watcher audittemplate list' returns deleted Audit Templates

Bug #1761956 reported by Egor Panfilov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
watcher
Fix Released
Undecided
Egor Panfilov

Bug Description

When I call for list of Audit Templates, I get next pretty response

+--------------------------------------+------+-------+----------+
| UUID | Name | Goal | Strategy |
+--------------------------------------+------+-------+----------+
| 2ca45261-eab9-4061-91ca-7b42445d7ca0 | at_1 | dummy | None |
| d1176ce6-5703-44db-a114-9f207236a9d9 | at_3 | dummy | None |
+--------------------------------------+------+-------+----------+

When I want to list Audit Templates filtered by concrete goal

   $ watcher audittemplate list --goal dummy

I got next strange result:

+--------------------------------------+------+-------+----------+
| UUID | Name | Goal | Strategy |
+--------------------------------------+------+-------+----------+
| 2ca45261-eab9-4061-91ca-7b42445d7ca0 | at_1 | dummy | None |
| e8f59af2-1832-4adf-854d-1fb081a96d0c | at_2 | dummy | None |
| d1176ce6-5703-44db-a114-9f207236a9d9 | at_3 | dummy | None |
+--------------------------------------+------+-------+----------+

If we do

   $ watcher audittemplate show at_2

response would be like this

AuditTemplate at_2 could not be found (HTTP 404)

So, we could conclude that when we add filter by goal API also returns deleted Audit Templates.

Tags: api
Egor Panfilov (erakli)
Changed in watcher:
assignee: nobody → Egor Panfilov (erakli)
status: New → In Progress
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to watcher (master)

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to watcher (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/563437

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

Reviewed: https://review.openstack.org/559481
Committed: https://git.openstack.org/cgit/openstack/watcher/commit/?id=aa74817686d12825730f377b51fbfe020490ae58
Submitter: Zuul
Branch: master

commit aa74817686d12825730f377b51fbfe020490ae58
Author: Egor Panfilov <email address hidden>
Date: Sat Apr 7 12:41:15 2018 +0300

    Added _get_model_list base method for all get_*_list methods

    When we call audittemplate list without filters, it returns all Audit
    Templates that are not deleted, as expected. If we add any filter to
    query and context.show_deleted is None (we request only current AT),
    query.filter_by adds filter to joined table (for example, goals, results
     in a query like JOIN goals ... WHERE ... goals.deleted_at IS NULL) not
    to model's table (AuditTemplate in our case).

    We change call for filter_by to filter, explicitly point to model that
    we want to filter.

    Also, we moved query generating code to new method _get_model_list(). As
    a result we applied same fix to all of the other models.

    Change-Id: I4d2f44fa149aee564c62a69822c6ad79de5bba8a
    Closes-bug: 1761956

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

Reviewed: https://review.openstack.org/563437
Committed: https://git.openstack.org/cgit/openstack/watcher/commit/?id=d23e7f0f8cea8f0ac1392b40c467b27f8161489c
Submitter: Zuul
Branch: master

commit d23e7f0f8cea8f0ac1392b40c467b27f8161489c
Author: Egor Panfilov <email address hidden>
Date: Sun Apr 22 02:32:02 2018 +0300

    Updated tests on bug, when get list returns deleted items

    In I4d2f44fa149aee564c62a69822c6ad79de5bba8a we introduced new
    _get_model_list method that introduces unify way for retrieving models
    from db. This commit adds tests that do checks on bug 1761956, when
    selecting with filter() method could return deleted entites.

    Change-Id: I12df4af70bcc25654a0fb276ea7145d772d891e2
    Related-Bug: 1761956

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

This issue was fixed in the openstack/watcher 1.10.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.