Internal Server Error when attempring to use an incorrect URL within the metadata API

Bug #2059128 reported by Anton Kurbatov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
In Progress
Undecided
Anton Kurbatov

Bug Description

When trying to GET a non-existent metadata key within the VM, like '/latest/meta-data/hostname/abc', the Nova metadata service responses with a 500 HTTP status code:

Inside a VM:

$ curl http://169.254.169.254/latest/meta-data/hostname/abc
<html>
 <head>
  <title>500 Internal Server Error</title>
 </head>
 <body>
  <h1>500 Internal Server Error</h1>
  An unknown error has occurred. Please try your request again.<br /><br />

 </body>
</html>$

The nova metadata service logs:

CRITICAL nova [None req-3286f047-98c4-41c8-a11b-02a140fd2e4d None None] Unhandled error: TypeError: string indices must be integers
ERROR nova Traceback (most recent call last):
ERROR nova File "/usr/local/lib/python3.9/site-packages/paste/urlmap.py", line 216, in __call__
ERROR nova return app(environ, start_response)
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/dec.py", line 129, in __call__
ERROR nova resp = self.call_func(req, *args, **kw)
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/dec.py", line 193, in call_func
ERROR nova return self.func(req, *args, **kwargs)
ERROR nova File "/usr/local/lib/python3.9/site-packages/oslo_middleware/base.py", line 124, in __call__
ERROR nova response = req.get_response(self.application)
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/request.py", line 1313, in send
ERROR nova status, headers, app_iter = self.call_application(
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/request.py", line 1278, in call_application
ERROR nova app_iter = application(self.environ, start_response)
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/dec.py", line 129, in __call__
ERROR nova resp = self.call_func(req, *args, **kw)
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/dec.py", line 193, in call_func
ERROR nova return self.func(req, *args, **kwargs)
ERROR nova File "/usr/local/lib/python3.9/site-packages/oslo_middleware/base.py", line 124, in __call__
ERROR nova response = req.get_response(self.application)
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/request.py", line 1313, in send
ERROR nova status, headers, app_iter = self.call_application(
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/request.py", line 1278, in call_application
ERROR nova app_iter = application(self.environ, start_response)
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/dec.py", line 129, in __call__
ERROR nova resp = self.call_func(req, *args, **kw)
ERROR nova File "/usr/local/lib/python3.9/site-packages/webob/dec.py", line 193, in call_func
ERROR nova return self.func(req, *args, **kwargs)
ERROR nova File "/opt/stack/nova/nova/api/metadata/handler.py", line 129, in __call__
ERROR nova data = meta_data.lookup(req.path_info)
ERROR nova File "/opt/stack/nova/nova/api/metadata/base.py", line 576, in lookup
ERROR nova data = self.get_ec2_item(path_tokens[1:])
ERROR nova File "/opt/stack/nova/nova/api/metadata/base.py", line 308, in get_ec2_item
ERROR nova return find_path_in_tree(data, path_tokens[1:])
ERROR nova File "/opt/stack/nova/nova/api/metadata/base.py", line 737, in find_path_in_tree
ERROR nova data = data[path_tokens[i]]
ERROR nova TypeError: string indices must be integers
ERROR nova
[pid: 156048|app: 0|req: 5/9] 10.136.16.184 () {40 vars in 687 bytes} [Tue Mar 26 04:37:44 2024] GET /latest/meta-data/hostname/abc => generated 0 bytes in 82 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

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

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/nova/+/914249

Changed in nova:
status: New → In Progress
Changed in nova:
assignee: nobody → Anton Kurbatov (akurbatov)
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.