Can't boot instance because of instance_type wrong pass

Bug #788265 reported by Mike Scherbakov
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Sandy Walsh

Bug Description

[root@cloud ~]# nova boot --flavor 1 --image 365320335 mike
datetime.datetime(2011, 5, 25, 17, 19, 57) is not JSON serializable (HTTP 500)

Trace in nova-api:
2011-05-25 21:52:36,949 DEBUG nova.rpc [-] Making asynchronous cast on scheduler... from (pid=4237) cast /usr/lib/python2.7/site-packages/nova/rpc.py:411
2011-05-25 21:52:36,994 ERROR nova.api.openstack [-] Caught error: datetime.datetime(2011, 5, 25, 17, 19, 57) is not JSON serializable
(nova.api.openstack): TRACE: Traceback (most recent call last):
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/nova/api/openstack/__init__.py", line 59, in __call__
(nova.api.openstack): TRACE: return req.get_response(self.application)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/webob/request.py", line 919, in get_response
(nova.api.openstack): TRACE: application, catch_exc_info=False)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/webob/request.py", line 887, in call_application
(nova.api.openstack): TRACE: app_iter = application(self.environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/routes/middleware.py", line 131, in __call__
(nova.api.openstack): TRACE: response = self.app(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/webob/dec.py", line 147, in __call__
(nova.api.openstack): TRACE: resp = self.call_func(req, *args, **self.kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/webob/dec.py", line 208, in call_func
(nova.api.openstack): TRACE: return self.func(req, *args, **kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/nova/wsgi.py", line 364, in __call__
(nova.api.openstack): TRACE: result = method(**arg_dict)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/nova/api/openstack/servers.py", line 183, in create
(nova.api.openstack): TRACE: injected_files=injected_files)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/nova/compute/api.py", line 268, in create
(nova.api.openstack): TRACE: "injected_files": injected_files}})
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/nova/rpc.py", line 415, in cast
(nova.api.openstack): TRACE: publisher.send(msg)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/carrot/messaging.py", line 765, in send
(nova.api.openstack): TRACE: serializer=serializer)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/carrot/messaging.py", line 690, in create_message
(nova.api.openstack): TRACE: serializer=serializer)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/carrot/serialization.py", line 144, in encode
(nova.api.openstack): TRACE: payload = encoder(data)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/anyjson/__init__.py", line 124, in <lambda>
(nova.api.openstack): TRACE: serialize = lambda value: implementation.serialize(value)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/site-packages/anyjson/__init__.py", line 86, in serialize
(nova.api.openstack): TRACE: raise TypeError(*exc.args)
(nova.api.openstack): TRACE: TypeError: datetime.datetime(2011, 5, 25, 17, 19, 57) is not JSON serializable
(nova.api.openstack): TRACE:

After commenting instance_type in RPC call it works fine:
            rpc.cast(context,
                     FLAGS.scheduler_topic,
                     {"method": "run_instance",
                      "args": {"topic": FLAGS.compute_topic,
                               "instance_id": instance_id,
                               #"instance_type": instance_type,
                               "availability_zone": availability_zone,
                               "injected_files": injected_files}})

[root@cloud ~]# nova-manage --version
OpenStack Nova version: 2011.3-dev (2011.3-nova:tarmac-20110524231040-0tt6rxdaf77re6es)

Related branches

Revision history for this message
Xavi Campa (xavicampa) wrote :

In version:
2011.3-dev (2011.3-workspace:tarmac-20110602174653-azonyll6ctjjtxvf)

Commenting the "request_spec" argument makes it work:
     rpc.cast(context,
                     FLAGS.scheduler_topic,
                     {"method": "run_instance",
                      "args": {"topic": FLAGS.compute_topic,
                               "instance_id": instance_id,
                               #"request_spec": {
                               # 'instance_type': instance_type,
                               # 'filter':
                               # 'nova.scheduler.host_filter.'
                               # 'InstanceTypeFilter',
                               #},
                               "availability_zone": availability_zone,
                               "injected_files": injected_files,
                               "admin_password": admin_password,
                              },
                     })

See link for a possible explanation of the exception:
http://stackoverflow.com/questions/455580/json-datetime-between-python-and-javascript/2680060#2680060

Revision history for this message
Max Lvov (usrleon) wrote :

[root@cloud ~]$ nova boot --flavor 1 --image 1206608969 test
datetime.datetime(2011, 5, 20, 12, 25, 49) is not JSON serializable (HTTP 500)

[root@cloud ~]$ sudo nova-manage version list
2011.3-dev (2011.3-nova:<email address hidden>)

Changed in nova:
assignee: nobody → Sandy Walsh (sandy-walsh)
Revision history for this message
Sandy Walsh (sandy-walsh) wrote :

Why am I not seeing this problem in my environment? I'm able to create instances without issue.

Which version of json are you running?

Revision history for this message
Yuriy Taraday (yorik-sar) wrote :

This issue does appear only on custom created instance types, because they have real time instead of None in created_at field.
Built-in (EC2-like) instance types are not affected.

Revision history for this message
Xavi Campa (xavicampa) wrote : Re: [Bug 788265] Re: Can't boot instance because of instance_type wrong pass
Download full text (5.5 KiB)

I can confirm I'm testing with custom instance types.

2011/6/22 Yuriy Taraday <email address hidden>

> This issue does appear only on custom created instance types, because they
> have real time instead of None in created_at field.
> Built-in (EC2-like) instance types are not affected.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/788265
>
> Title:
> Can't boot instance because of instance_type wrong pass
>
> Status in OpenStack Compute (Nova):
> New
>
> Bug description:
> [root@cloud ~]# nova boot --flavor 1 --image 365320335 mike
> datetime.datetime(2011, 5, 25, 17, 19, 57) is not JSON serializable (HTTP
> 500)
>
> Trace in nova-api:
> 2011-05-25 21:52:36,949 DEBUG nova.rpc [-] Making asynchronous cast on
> scheduler... from (pid=4237) cast
> /usr/lib/python2.7/site-packages/nova/rpc.py:411
> 2011-05-25 21:52:36,994 ERROR nova.api.openstack [-] Caught error:
> datetime.datetime(2011, 5, 25, 17, 19, 57) is not JSON serializable
> (nova.api.openstack): TRACE: Traceback (most recent call last):
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/nova/api/openstack/__init__.py", line 59,
> in __call__
> (nova.api.openstack): TRACE: return req.get_response(self.application)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/webob/request.py", line 919, in
> get_response
> (nova.api.openstack): TRACE: application, catch_exc_info=False)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/webob/request.py", line 887, in
> call_application
> (nova.api.openstack): TRACE: app_iter = application(self.environ,
> start_response)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/webob/dec.py", line 159, in __call__
> (nova.api.openstack): TRACE: return resp(environ, start_response)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/webob/dec.py", line 159, in __call__
> (nova.api.openstack): TRACE: return resp(environ, start_response)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/webob/dec.py", line 159, in __call__
> (nova.api.openstack): TRACE: return resp(environ, start_response)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/routes/middleware.py", line 131, in
> __call__
> (nova.api.openstack): TRACE: response = self.app(environ,
> start_response)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/webob/dec.py", line 159, in __call__
> (nova.api.openstack): TRACE: return resp(environ, start_response)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/webob/dec.py", line 147, in __call__
> (nova.api.openstack): TRACE: resp = self.call_func(req, *args,
> **self.kwargs)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/webob/dec.py", line 208, in call_func
> (nova.api.openstack): TRACE: return self.func(req, *args, **kwargs)
> (nova.api.openstack): TRACE: File
> "/usr/lib/python2.7/site-packages/nova/wsgi.py", line 364, in __call__
> (nova.api.openstack): TRACE: ...

Read more...

Changed in nova:
status: New → Confirmed
Revision history for this message
Sandy Walsh (sandy-walsh) wrote :

Ah ... interesting. Ok, let me look further. Thanks.

Thierry Carrez (ttx)
Changed in nova:
status: Confirmed → In Progress
importance: Undecided → Low
Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → diablo-2
Thierry Carrez (ttx)
Changed in nova:
milestone: diablo-2 → 2011.3
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.