Host "get" is case-insensitive while host "update" is not

Bug #996879 reported by Gabriel Hurley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Joe Gordon

Bug Description

Using the hosts API extension with a host named "node1" I can make the following three GET calls and get the same result:

http://10.144.11.107:8774/v2/6aa32ccc519140dab38ee5d231df7ed4/os-hosts/node1
http://10.144.11.107:8774/v2/6aa32ccc519140dab38ee5d231df7ed4/os-hosts/NODE1
http://10.144.11.107:8774/v2/6aa32ccc519140dab38ee5d231df7ed4/os-hosts/nOdE1

But if I make an update call (PUT), only the lowercase (correct) version works.

http://10.144.11.107:8774/v2/6aa32ccc519140dab38ee5d231df7ed4/os-hosts/node1

Otherwise a 500 response is returned due to the API not catching exception.HostNotFound properly.

Changed in nova:
status: New → Confirmed
Revision history for this message
Ying Chun Guo (daisy-ycguo) wrote :

When getting hosts, it uses SQLAlchemy to query database, which is case insensitive.

When updating hosts, firstly it will check whether the host exists. Scheduler RPC API is used to get the host list. And then, it will verify whether the host name is in the host list, where case is sensitive.

The domain names of URL are not case-sensitive, while the rest of the URL might be. If we change the "GET" url to case sensitive, we need to change the definition of table "services". If we change the "PUT" url to be case insensitive, we just need to change the code to covert all characters to lower case when comparing. It's quite easy. I perfer the easier one.

REFER TO: http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html
"For nonbinary strings (CHAR, VARCHAR, TEXT), string searches use the collation of the comparison operands. The default character set and collation are latin1 and latin1_swedish_ci, so nonbinary string comparisons are case insensitive by default."

Thierry Carrez (ttx)
Changed in nova:
importance: Undecided → Low
importance: Low → Medium
Changed in nova:
assignee: nobody → Ying Chun Guo (daisy-ycguo)
Changed in nova:
assignee: Ying Chun Guo (daisy-ycguo) → nobody
Changed in nova:
milestone: none → grizzly-rc1
Revision history for this message
Joe Gordon (jogo) wrote :

Retried this on latest develop (G3 -> G-RC1) and the GETS work as reported. But the PUT doesn't work. because the hostname from the request is used for RPC(RPC is case sensitive) instead of the hostname as recorded in the DB (which will always have the proper case).

Joe Gordon (jogo)
Changed in nova:
assignee: nobody → Joe Gordon (jogo)
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/23765

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/23765
Committed: http://github.com/openstack/nova/commit/0ef60856fb2f1f1fd83647c3422e1b510a871ebd
Submitter: Jenkins
Branch: master

commit 0ef60856fb2f1f1fd83647c3422e1b510a871ebd
Author: Joe Gordon <email address hidden>
Date: Thu Mar 7 00:01:29 2013 +0000

    Make 'os-hosts/node1' case sensitivity defer to DB

    RPC is case sensitive, but URL is not, and DB can be. So pull host_name from DB
    in HostAPI RPC layer instead of from passed in from URL. This means RPC will
    always get the proper capitalization, and case sensitivity is defined in DB layer.

    Fix bug 996879

    Change-Id: I448dd4ec3aec4af1adf4487f26ea996db572fa3d

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-rc1 → 2013.1
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.