ironic can't find nodes whose name ends in ".<mimetype>"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ironic |
Fix Released
|
High
|
Ruby Loo |
Bug Description
# Create a new node
% ironic node-create -d fake --name test.me
+------
| Property | Value |
+------
| chassis_uuid | |
| driver | fake |
| driver_info | {} |
| extra | {} |
| name | test.me |
| properties | {} |
| uuid | 78970da1-
+------
# Display it
% ironic node-show test.me
Not Found (HTTP 404)
# Erm. It's there:
% ironic node-list | grep test.me
| 78970da1-
# And we can get it by uuid:
% ironic node-show 78970da1-
| name | test.me
# It appears to be short circuiting somewhere before getting to ironic, as ironic returns a
# different 404:
% ironic node-show nosuchnode
Node nosuchnode could not be found. (HTTP 404)
Eventually we traverse far enough down the rabbit hole to pecan/core.py where in find_controller(), it tries to be helpful:
425 def find_controller
426 '''
427 The main request handler for Pecan applications.
428 '''
[..]
445 # attempt to guess the content type based on the file extension
446 if self.guess_
447 and not pecan_state[
448 and '.' in path:
449 _, extension = splitext(
450
451 # preface with a letter to ensure compat for 2.5
452 potential_type = guess_type('x' + extension)[0]
453
454 if extension and potential_type is not None:
455 path = ''.join(
456 pecan_state[
457 pecan_state[
(Pdb) p self.guess_
True
(Pdb) p pecan_state
{'routing_path': u'/v1/nodes/
(Pdb) p path
u'/v1/nodes/
So we fall in and hit 449, which sets extension to ".me", which is apparently the mime type for:
(Pdb) p potential_type
'application/
So we fall into 454. This sets us up for failure at 510:
510 elif cfg.get(
511 pecan_state[
512
513 msg = "Controller '%s' defined does not support content_type " + \
514 "'%s'. Supported type(s): %s"
515 logger.error(
516 msg % (
517 controller.
518 pecan_state[
519 content_
520 )
521 )
522 -> raise exc.HTTPNotFound
because pecan is configured only to handle "application/json" requests:
(Pdb) p cfg['content_type']
'application/json'
and we've explicitly set the content type of this request to 'application/
So, basically, if your nodename ends in ".<mimetype>", pecan won't let you see it because it never passes the request off to ironic:
% ironic node-update 78970da1-
% ironic node-show test.mp3
Not Found (HTTP 404)
% ironic node-update 78970da1-
% ironic node-show test.doc
Not Found (HTTP 404)
% ironic node-update 78970da1-
% ironic node-show test.html
Not Found (HTTP 404)
% ironic node-update 78970da1-
% ironic node-show test.ok | grep name
| name | test.ok
A workaround would appear to be getting pecan's guess_content_
E.g.
--- /usr/lib/
+++ /usr/lib/
@@ -27,6 +27,7 @@
'static_root': '%(confdir)
'debug': False,
'enable_acl': True,
+ 'guess_
'acl_
'/',
'/v1'
--- /usr/lib/
+++ /usr/lib/
@@ -54,7 +54,6 @@
filename = config.
return pecan.configura
-
def setup_app(
app_hooks = [hooks.
@@ -78,6 +77,7 @@
+ guess_content_
)
Changed in ironic: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
Changed in ironic: | |
assignee: | nobody → Vadim Hmyrov (vhmyrov) |
Changed in ironic: | |
status: | Confirmed → Triaged |
Changed in ironic: | |
assignee: | Vadim Hmyrov (vhmyrov) → Galyna Zholtkevych (gzholtkevych) |
Changed in ironic: | |
assignee: | Galyna Zholtkevych (gzholtkevych) → nobody |
status: | In Progress → Triaged |
Changed in ironic: | |
assignee: | nobody → Dmitry Tantsur (divius) |
Changed in ironic: | |
assignee: | Dmitry Tantsur (divius) → Ruby Loo (rloo) |
Thanks for reporting! The proposed fix should work. We can't microversion this change, so seems that we should set it to False by default, with some deprecation warning maybe? And after some time just always set guess_content_ type_from_ ext=True, as such possibility does not make much sense anyway - ironic supports only json content-type. Not really sure how to do that deprecation, apart from release note mention...