Error Compute API - Live-Migrate Server

Bug #1746796 reported by Marcio Feliciano do Prado
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
New
Undecided
Unassigned

Bug Description

Good afternoon,

I'm experiencing difficulties with Computing API.

When I migrate VMs by command line everything works fine.

According to the command: openstack server migrate 7ca6ee39-bab1-422c-a19f-1b73d2aeaf31 --live compute1 (OK)

But when I try to migrate through the API I get the following error:

{"computeFault": {"message": "Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.\n<type 'exceptions.KeyError'>", "code": 500}}

To request a migration through the API I am using the following Json:

Note: The variable $ TOKEN_AUTENTICACAO is all right, already testing.

        curl -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN_AUTENTICACAO" \
 -X POST http://controller:8774/v2/servers/7ca6ee39-bab1-422c-a19f-1b73d2aeaf31/action \
        -d '{
                "os-migrateLive": {
                        "host": "compute3",
                        "block_migration": "auto",
                        "force": false
                }
        }'

Can someone help me please? Sorry for English, I'm Brazilian.

Follow the /var/log/nova/nova-api.log log

2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions [req-2e1b20c9-ca88-47b1-8ed3-976ad50c3f6e 77fe89f8145846bf9240428144f96fba 00e4a214dab74548b8728df515a2a9d7 - default default] Unexpected exception in API method
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions Traceback (most recent call last):
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/dist-packages/nova/api/openstack/extensions.py", line 338, in wrapped
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions return f(*args, **kwargs)
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/dist-packages/nova/api/validation/__init__.py", line 108, in wrapper
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions return func(*args, **kwargs)
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/dist-packages/nova/api/validation/__init__.py", line 108, in wrapper
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions return func(*args, **kwargs)
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/dist-packages/nova/api/validation/__init__.py", line 108, in wrapper
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions return func(*args, **kwargs)
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/dist-packages/nova/api/openstack/compute/migrate_server.py", line 90, in _migrate_live
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions disk_over_commit = body["os-migrateLive"]["disk_over_commit"]
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions KeyError: 'disk_over_commit'
2018-02-01 17:54:34.413 3532 ERROR nova.api.openstack.extensions
2018-02-01 17:54:34.414 3532 INFO nova.api.openstack.wsgi [req-2e1b20c9-ca88-47b1-8ed3-976ad50c3f6e 77fe89f8145846bf9240428144f96fba 00e4a214dab74548b8728df515a2a9d7 - default default] HTTP exception thrown: Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<type 'exceptions.KeyError'>
2018-02-01 17:54:34.415 3532 INFO nova.osapi_compute.wsgi.server [req-2e1b20c9-ca88-47b1-8ed3-976ad50c3f6e 77fe89f8145846bf9240428144f96fba 00e4a214dab74548b8728df515a2a9d7 - default default] 10.0.0.2 "POST /v2/servers/74eb35a6-e9f5-4f44-b058-63dab362fc2e/action HTTP/1.1" status: 500 len: 399 time: 0.0144310

Tags: api
Revision history for this message
Marcio Feliciano do Prado (marcio.prado) wrote :

I forgot to say, I'm using Ocata and Ubuntu Server.

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

Your English is excellent, thank you for the detailed bug report. :)

The CLI will make the request at version 2.1 and pass in defaults for you most likely.

It looks like the issue is that you're making a 2.1 request and not providing an entry for "disk_over_commit":

https://developer.openstack.org/api-ref/compute/#live-migrate-server-os-migratelive-action

That field was dropped from the request in microversion 2.25, but until then you have to specify it:

https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#maximum-in-mitaka

We shouldn't get a KeyError though, that looks like a bug in the request API jsonschema validation.

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

This all looks correct to me:

https://github.com/openstack/nova/blob/d189e682277b4b5d5b70c46a2ad065e29ccccb22/nova/api/openstack/compute/schemas/migrate_server.py#L48

You should have gotten a 400 response rather than a 500. My guess is you were hitting the legacy v2 API code which didn't use jsonschema validation and that's why you got a 500 error. That code is gone now and you should be hitting the 2.1 endpoint.

OSC defaults disk_over_commit=False:

https://github.com/openstack/python-openstackclient/blob/stable/ocata/openstackclient/compute/v2/server.py#L1054

So retry your request with that, or use microversion>=2.25.

Changed in nova:
status: New → Invalid
Revision history for this message
Matt Riedemann (mriedem) wrote :

Oh here we go:

https://review.openstack.org/#/c/479197/

You need that fix which is in 15.0.7.

Changed in nova:
status: Invalid → New
Revision history for this message
Marcio Feliciano do Prado (marcio.prado) wrote :

Thank.

The problem really was the "disk_over_commit".

I added and it worked normally ...

That's why I like Linux ... The community is grade 10!

Hugs.

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.