Daily usage do not check date range validity

Bug #1331427 reported by Matthias Runge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
High
Matthias Runge

Bug Description

Visit
http://<host>/dashboard/admin/metering/report
and choose "other period"
For from/to take any value other than date.

This will result in ValueError at /admin/metering/report

Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/site-packages/horizon/decorators.py" in dec
  38. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/horizon/decorators.py" in dec
  86. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/horizon/decorators.py" in dec
  54. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/horizon/decorators.py" in dec
  38. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/horizon/decorators.py" in dec
  86. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/views/generic/base.py" in view
  69. return self.dispatch(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
  87. return handler(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/horizon/tables/views.py" in post
  162. return self.get(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/horizon/tables/views.py" in get
  154. handled = self.construct_tables()
File "/usr/lib/python2.7/site-packages/horizon/tables/views.py" in construct_tables
  137. tables = self.get_tables().values()
File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/admin/metering/views.py" in get_tables
  106. project_data = self.load_data(self.request)
File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/admin/metering/views.py" in load_data
  153. 3600 * 24)
File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/admin/metering/views.py" in query_data
  246. date_options)
File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/admin/metering/views.py" in _calc_date_args
  225. raise ValueError("The dates haven't been "

Exception Type: ValueError at /admin/metering/report
Exception Value: The dates haven't been recognized

Revision history for this message
Matthias Runge (mrunge) wrote :

By the way, the view should be changed to use http post instead of get!

Changed in horizon:
importance: Undecided → High
Changed in horizon:
assignee: nobody → Nikunj Aggarwal (nikunj2512)
Matthias Runge (mrunge)
Changed in horizon:
status: New → Triaged
Revision history for this message
Nikunj Aggarwal (nikunj2512) wrote :

I started working in this bug but i don't see from where i can select "choose "other period"" option.

It will be helpful, if You upload a screenshot.

Revision history for this message
Julie Pichon (jpichon) wrote :

1. Log in as admin
2. Go to Resource Usage
3. In the "Period" dropdown, choose "Other"

Hope this helps!

On the front-end side, ideally these forms should call the generic datepicker code that is used in other parts of Horizon (like e.g. the datepicker).

https://github.com/openstack/horizon/blob/2b2015a345/horizon/static/horizon/js/horizon.forms.js#L59

Matthias Runge (mrunge)
Changed in horizon:
assignee: Nikunj Aggarwal (nikunj2512) → Matthias Runge (mrunge)
Revision history for this message
Lawrance (jing) wrote :

will try tomorrow!

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

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

Changed in horizon:
status: Triaged → In Progress
Changed in horizon:
assignee: Matthias Runge (mrunge) → Nikunj Aggarwal (nikunj2512)
Changed in horizon:
assignee: Nikunj Aggarwal (nikunj2512) → Matthias Runge (mrunge)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/107011
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=ca2e10c3e8efa6d5ae07a04ea0cd6a029dad7319
Submitter: Jenkins
Branch: master

commit ca2e10c3e8efa6d5ae07a04ea0cd6a029dad7319
Author: Matthias Runge <email address hidden>
Date: Tue Oct 14 11:26:42 2014 +0200

    Refactor metering dashboard

    - check date range for validity
    - use django forms
    - treat times according to users timezone

    Change-Id: I68182ddb4b00d19e54011722ebc770d9aa8e725c
    Closes-bug: #1331427
    Closes-bug: #1331434
    Closes-bug: #1288512

Changed in horizon:
status: In Progress → Fix Committed
Akihiro Motoki (amotoki)
Changed in horizon:
milestone: none → kilo-1
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: kilo-1 → 2015.1.0
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.