Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZAPI-660 Requests to /vms hang forever which have a "fields" param and match no VMs #2

Closed
wants to merge 1 commit into from

Conversation

arekinath
Copy link
Contributor

On any "list VMs" request that asks for a "fields" limit, if the query returns no results, we currently hang forever.

I first observed this when asking for an offset >= # of VMs. In this case, the req.vms array is empty. Currently we call Object.keys() on req.vms[0] in this case, which spits an error (since vms[0] is undefined). What we want to do is just return [].

Example of the error message in the vmapi logs:

[2015-06-11T01:19:01.505Z]  INFO: vmapi/api/33158 on 836d01b7-ff64-4717-958d-2bbd0cae17c6:  (req_id=d7a46a50-0fd7-11e5-b667-e3e634d86ba9)
    TypeError: Object.keys called on non-object
        at Function.keys (native)
        at Server.renderVms (/opt/smartdc/vmapi/lib/endpoints/vms.js:66:27)
        at next (/opt/smartdc/vmapi/node_modules/restify/lib/server.js:731:30)
        at f (/opt/smartdc/vmapi/node_modules/restify/node_modules/once/once.js:16:25)
        at /opt/smartdc/vmapi/lib/endpoints/vms.js:219:20
        at EventEmitter.<anonymous> (/opt/smartdc/vmapi/lib/apis/moray.js:522:20)
        at EventEmitter.g (events.js:180:16)
        at EventEmitter.emit (events.js:92:17)
        at EventEmitter.<anonymous> (/opt/smartdc/vmapi/node_modules/moray/lib/objects.js:197:13)
        at EventEmitter.g (events.js:180:16)
    --
    url: /vms?state=active&fields=uuid%2Cstate%2Cdestroyed%2Calias%2Cowner_uuid%2Cnics%2Cserver_uuid&offset=799&limit=799
    --
    params: {
      "state": "active",
      "fields": "uuid,state,destroyed,alias,owner_uuid,nics,server_uuid",
      "offset": "799",
      "limit": "799"
    }

I've attempted to add some tests in vms.test.js to cover this case, but I can't quite figure out how the ordering of tests is meant to work in there (they seem to just be set as keys on the exports object, which shouldn't have any ordering guarantee? but they assume ordering by re-using variables like vmLocation between tests...). Hopefully they work.

This has also been reported on IRC by ep1a in #smartos, on a request with no limit/offset parameters:

$ sdc-vmapi /vms?fields=nics&query=(alias%3Ddoesnotexist)
(hangs forever)

@arekinath arekinath changed the title Don't spit errors when asked for offset >= # of VMs Hanging forever on requests with "fields" that return no results Aug 20, 2015
@arekinath arekinath changed the title Hanging forever on requests with "fields" that return no results ZAPI-660 Requests to /vms hang forever which have a "fields" param and match no VMs Aug 20, 2015
@arekinath
Copy link
Contributor Author

Merged as cff6bd4

@arekinath arekinath closed this Aug 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant