SchedulerReportClient.put with empty (not None) payload errors 415

Bug #1744786 reported by Eric Fried
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Eric Fried

Bug Description

https://github.com/openstack/nova/blob/f0d830d56d20c7f34372cd3c68d13a94bdf645a6/nova/scheduler/client/report.py#L295-L302

 295 def put(self, url, data, version=None):
 296 # NOTE(sdague): using json= instead of data= sets the
 297 # media type to application/json for us. Placement API is
 298 # more sensitive to this than other APIs in the OpenStack
 299 # ecosystem.
 300 kwargs = {'microversion': version}
 301 if data:
 302 kwargs['json'] = data

On line 301, if data is a False value other than None, we won't set the json kwarg, so Session won't set the content type to application/json, and we'll run afoul of:

    <html>
     <head>
      <title>415 Unsupported Media Type</title>
     </head>
     <body>
      <h1>415 Unsupported Media Type</h1>
      The request media type None is not supported by this server.
    <br /><br />
    The media type None is not supported, use application/json
     </body>
    </html>

A normal "workaround" - which is being used for e.g. inventories - is for the caller to check for "empty" and hit the DELETE API instead.

But we don't have a DELETE API for resource provider aggregates (/resource_providers/{u}/aggregates).

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

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

Changed in nova:
assignee: nobody → Eric Fried (efried)
status: New → In Progress
melanie witt (melwitt)
tags: added: placement scheduler
Changed in nova:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/536545
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=5a4872ed306ad33a2bceb50846a4b38ad3b95c73
Submitter: Zuul
Branch: master

commit 5a4872ed306ad33a2bceb50846a4b38ad3b95c73
Author: Eric Fried <email address hidden>
Date: Mon Jan 22 13:49:52 2018 -0600

    Report Client: PUT empty (not None) JSON data

    Previously if a False-ish payload was sent to SchedulerReportClient.put,
    we wouldn't send it through in the API call at all. But False-ish
    payloads may be legitimate: e.g. there is currently no DELETE API for
    /resource_providers/{u}/aggregates so this is how you would remove all
    aggregate associations for a provider.

    In any case, placement's PUT API refuses to accept a request that
    doesn't have Content-Type: application/json, which is set automatically
    by Session if json is not None.

    With this change set, we send payloads through to PUT unless they're
    actually None.

    Change-Id: I69d2b16d515590907ca0e0dc4da77dcf8e539976
    Closes-Bug: #1744786

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 17.0.0.0rc1

This issue was fixed in the openstack/nova 17.0.0.0rc1 release candidate.

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.