Evaluation of archive_policy_rules is unspecified

Bug #1501344 reported by Julien Danjou
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gnocchi
Fix Released
Medium
gordon chung

Bug Description

It's not written in the doc so we don't know if the code has any check on that.

Could be useful to know if we want to use an archive_policy_rule with '*' as metric_pattern.

Julien Danjou (jdanjou)
Changed in gnocchi:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Alejandro Comisario (alejandro-f) wrote :

here's our fix to the issue, and to define a default rule to match everything that doesnt match previous criteria.

the result is as follow ( sorting the policy rules by metric_pattern ) in a way that a rule with "*" will allways analyzed at the end acting as DEFAULT rule.

+----------+---------------------+----------------+
| name | archive_policy_name | metric_pattern |
+----------+---------------------+----------------+
| test_mem | test_mem | mem* |
| test54 | maximo1 | disk.usage.* |
| test_io | test_io | disk* |
| test55 | alejandrito1 | cpu.idle.* |
| test_cpu | test_cpu | cpu* |
| default | default | * |
+----------+---------------------+----------------+

The proposed change is to change line :

https://github.com/openstack/gnocchi/blob/master/gnocchi/indexer/sqlalchemy.py#L166

and replace

aps = session.query(ArchivePolicyRule).all()

by

aps = session.query(ArchivePolicyRule).order_by(ArchivePolicyRule.metric_pattern.desc()).all()

gordon chung (chungg)
Changed in gnocchi:
assignee: nobody → gordon chung (chungg)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to gnocchi (master)

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

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

Reviewed: https://review.openstack.org/229600
Committed: https://git.openstack.org/cgit/openstack/gnocchi/commit/?id=5eb9baca68fac2e825ef79ad1e721e711044eea7
Submitter: Jenkins
Branch: master

commit 5eb9baca68fac2e825ef79ad1e721e711044eea7
Author: gordon chung <email address hidden>
Date: Wed Sep 30 16:09:34 2015 -0400

    match archive policy rule based on longest match

    currently, we use the first archive policy rule that we match based
    on querying the existing rules. this list of rules is unordered.
    this patch explicitly orders rules by metric_pattern so match against
    the longest match first.

    Change-Id: I4cc99ccbf98c1920d46ae259c81275953e9bfb03
    Co-Authored-By: Alejandro Comisario <email address hidden>
    Closes-bug: #1501344

Changed in gnocchi:
status: In Progress → Fix Committed
Julien Danjou (jdanjou)
Changed in gnocchi:
milestone: none → 1.3.0
status: Fix Committed → Fix Released
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.