Unexpected exception in API method: ValueError: year is out of range

Bug #1783338 reported by Nguyen Hoang Tung
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Confirmed
Medium
Unassigned

Bug Description

Openstack Pike
Nova ver 16.1.0
I'm having a problem with no way to fix it. Looking forward to being instructed.

While I click on Overview on the Dashboard. On CONTROLLER NODE the error appears:

At /var/log/httpd/error_log

[root @ controller01 ~] # tail -f /var/log/httpd/error_log
[Tue Jul 24 20:30:31.849925 2018] [:error] [pid 23501] WARNING horizon.exceptions Recoverable error: Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
[Tue Jul 24 20:30:31.849959 2018] [:error] [pid 23501] <type 'exceptions.ValueError'> (HTTP 500) (Request-ID: req-a09d7dde-82c4-44e2-93e3-0f30d4cf76d5)

At /var/log/nova/nova-api.log

[root@controller01 ~]# tail -f /var/log/nova/nova-api.log
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions [req-a09d7dde-82c4-44e2-93e3-0f30d4cf76d5 405a2d24984a4571b63c1d89fd27acc1 80a8f88b532f4cefbc1cffd377045a7a - default default] Unexpected exception in API method: ValueError: year is out of range
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions Traceback (most recent call last):
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/api/openstack/extensions.py", line 336, in wrapped
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions return f(*args, **kwargs)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/simple_tenant_usage.py", line 267, in index
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions return self._index(req, links=True)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/simple_tenant_usage.py", line 310, in _index
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions limit=limit, marker=marker)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/simple_tenant_usage.py", line 143, in _tenant_usages_for_period
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions limit, marker)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/simple_tenant_usage.py", line 118, in _get_instances_all_cells
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions marker=marker))
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1347, in get_active_by_window_joined
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions limit=limit, marker=marker)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 184, in wrapper
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions result = fn(cls, context, *args, **kwargs)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1317, in _get_active_by_window_joined
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions expected_attrs)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1198, in _make_instance_list
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions expected_attrs=expected_attrs)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 355, in _from_db_object
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions instance[field] = db_inst[field]
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 765, in __setitem__
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions setattr(self, name, value)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 72, in setter
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions field_value = field.coerce(self, name, value)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/oslo_versionedobjects/fields.py", line 195, in coerce
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions return self._type.coerce(obj, attr, value)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/oslo_versionedobjects/fields.py", line 461, in coerce
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions value = timeutils.parse_isotime(value)
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/oslo_utils/timeutils.py", line 67, in parse_isotime
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions raise ValueError(six.text_type(e))
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions ValueError: year is out of range
2018-07-24 20:30:31.843 7428 ERROR nova.api.openstack.extensions

Tags: api
Revision history for this message
Nguyen Hoang Tung (tung93st) wrote :
description: updated
description: updated
description: updated
tags: added: api
Revision history for this message
Ghanshyam Mann (ghanshyammann) wrote :

It seems input start and end dates are not iso8601 format But i cannot tell why we horizon should send date in those format.

Below is code flow for this error. One things we should surly do is to catch the value error on API side and return 400 for any unformulated dates.

- _get_instances_all_cells() method call the objects.InstanceList.get_active_by_window_joined() with period_start, period_stop which are start and end date from request. - https://github.com/openstack/nova/blob/e8a73c400846b5be0f12a2eea32bd2c5c5aeb370/nova/api/openstack/compute/simple_tenant_usage.py#L116

- objects.InstanceList.get_active_by_window_joined() will parse those dates with parse_isotime() - https://github.com/openstack/nova/blob/b58c7f033771e3ea228e4b40c796d1bc95a087f5/nova/objects/instance.py#L1347

- then oslo.utils throw value error as dates are not in iso8601 format- https://github.com/openstack/oslo.utils/blob/e43edb19d4c8c11ef6fccc08a37cf88b97d46731/oslo_utils/timeutils.py#L68

Revision history for this message
Ghanshyam Mann (ghanshyammann) wrote :

But from the error "ValueError: year is out of range" and screenshot of horizon, it seems it is complaining that 2018 is out or range.

I need to try and debug on what value nova get in this case.

Changed in nova:
status: New → Confirmed
assignee: nobody → Ghanshyam Mann (ghanshyammann)
importance: Undecided → Medium
Revision history for this message
Nguyen Hoang Tung (tung93st) wrote :

Yep!
After accessing the database, check the tables. I realize that some schools have been brought on for the wrong time. I made a fix, everything was working properly. Very thanks for the support.

Revision history for this message
Ghanshyam Mann (ghanshyammann) wrote :

nice, i also tried on master and it is working fine. Anyways let's handle the 500 error here.

Revision history for this message
Muhammad Hanif (muhammadhanif) wrote :

Hello, can you give me step by step to solve the problem? I have the same problem. Thank you,

Revision history for this message
Matt Riedemann (mriedem) wrote :

@gmann, do you still plan on working on this? You've been assigned for a few months with no proposed code changes.

Changed in nova:
assignee: Ghanshyam Mann (ghanshyammann) → nobody
Revision history for this message
jw (majw) wrote :

what tables and i should change?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.