Firmware update fails on Gen 8.1 due to newline in cookie header

Bug #1859616 reported by Mark Goddard
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
proliantutils
Fix Released
Undecided
Unassigned

Bug Description

I am trying to update firmware on a Gen 8.1 ilo using an ironic clean step. Here is my step:

[{
    "interface": "management",
    "step": "update_firmware",
    "args": {
        "firmware_update_mode": "ilo",
        "firmware_images":[
            {
                "url": "<url>",
                "checksum": "<csum>",
                "component": "ilo"
            }
        ]
    }
}]

This failed with the following error:

NodeCleaningFailure: Clean step update_firmware failed on node <node> with error: Invalid return character or leading space in header: Cookie

I added an exception log in the ironic ilo driver, and got this traceback:

doh: IloConnectionError: Invalid return character or leading space in header: Cookie
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ironic/drivers/modules/ilo/management.py", line 79, in _execute_ilo_clean_step
    clean_step(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/proliantutils/ilo/client.py", line 578, in update_firmware
    'update_firmware', firmware_url, component_type)
  File "/usr/lib/python2.7/site-packages/proliantutils/ilo/client.py", line 234, in _call_method
    return method(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/proliantutils/ilo/firmware_controller.py", line 91, in wrapper
    return func(self, filename, component_type)
  File "/usr/lib/python2.7/site-packages/proliantutils/ilo/ribcl.py", line 1118, in update_firmware
    d = self._request_ilo(root, extra_headers=extra_headers)
  File "/usr/lib/python2.7/site-packages/proliantutils/ilo/ribcl.py", line 152, in _request_ilo
    raise exception.IloConnectionError(e)
IloConnectionError: Invalid return character or leading space in header: Cookie

I then manually used a python interpreter with the IloClient client to call update_firmware, and found that the cookie has a '\r' newline. Adding the following line allowed the update to complete successfully:

cookie = cookie.strip()

Seen on proliantutils 2.4.0, also tested on 2.9.2.

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

Reviewed: https://review.opendev.org/702423
Committed: https://git.openstack.org/cgit/x/proliantutils/commit/?id=37afea2bbc5fdd17f69a094d81a060f9140ed24a
Submitter: Zuul
Branch: master

commit 37afea2bbc5fdd17f69a094d81a060f9140ed24a
Author: Mark Goddard <email address hidden>
Date: Tue Jan 14 13:37:33 2020 +0000

    Strip whitespace from cookie in firmware update

    When updating firmware, some devices return a cookie with a newline in.
    This can result in the following error:

    Invalid return character or leading space in header: Cookie

    This is due to the header validation in the requests library, which
    requires no newlines in headers.

    This change fixes the issue by stripping whitespace from the cookie.

    Change-Id: Ib2dab7beef0da415e8f2358b459ec1205bf688b4
    Closes-Bug: #1859616

Changed in proliantutils:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to proliantutils (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/708630

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to proliantutils (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/708631

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to proliantutils (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.opendev.org/708632

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to proliantutils (stable/stein)

Reviewed: https://review.opendev.org/708631
Committed: https://git.openstack.org/cgit/x/proliantutils/commit/?id=13fdad8650f01577ee0d19c8094d8e3cc0a93aa0
Submitter: Zuul
Branch: stable/stein

commit 13fdad8650f01577ee0d19c8094d8e3cc0a93aa0
Author: Mark Goddard <email address hidden>
Date: Tue Jan 14 13:37:33 2020 +0000

    Strip whitespace from cookie in firmware update

    When updating firmware, some devices return a cookie with a newline in.
    This can result in the following error:

    Invalid return character or leading space in header: Cookie

    This is due to the header validation in the requests library, which
    requires no newlines in headers.

    This change fixes the issue by stripping whitespace from the cookie.

    Change-Id: Ib2dab7beef0da415e8f2358b459ec1205bf688b4
    Closes-Bug: #1859616
    (cherry picked from commit 37afea2bbc5fdd17f69a094d81a060f9140ed24a)

tags: added: in-stable-stein
tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to proliantutils (stable/rocky)

Reviewed: https://review.opendev.org/708632
Committed: https://git.openstack.org/cgit/x/proliantutils/commit/?id=80e4f247b8a8d5ff1304a1af0b3f55e99e47e714
Submitter: Zuul
Branch: stable/rocky

commit 80e4f247b8a8d5ff1304a1af0b3f55e99e47e714
Author: Mark Goddard <email address hidden>
Date: Tue Jan 14 13:37:33 2020 +0000

    Strip whitespace from cookie in firmware update

    When updating firmware, some devices return a cookie with a newline in.
    This can result in the following error:

    Invalid return character or leading space in header: Cookie

    This is due to the header validation in the requests library, which
    requires no newlines in headers.

    This change fixes the issue by stripping whitespace from the cookie.

    Change-Id: Ib2dab7beef0da415e8f2358b459ec1205bf688b4
    Closes-Bug: #1859616
    (cherry picked from commit 37afea2bbc5fdd17f69a094d81a060f9140ed24a)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to proliantutils (stable/train)

Reviewed: https://review.opendev.org/708630
Committed: https://git.openstack.org/cgit/x/proliantutils/commit/?id=14ecc7b2fb742e821831bdbd37e1e212434b2194
Submitter: Zuul
Branch: stable/train

commit 14ecc7b2fb742e821831bdbd37e1e212434b2194
Author: Mark Goddard <email address hidden>
Date: Tue Jan 14 13:37:33 2020 +0000

    Strip whitespace from cookie in firmware update

    When updating firmware, some devices return a cookie with a newline in.
    This can result in the following error:

    Invalid return character or leading space in header: Cookie

    This is due to the header validation in the requests library, which
    requires no newlines in headers.

    This change fixes the issue by stripping whitespace from the cookie.

    Change-Id: Ib2dab7beef0da415e8f2358b459ec1205bf688b4
    Closes-Bug: #1859616
    (cherry picked from commit 37afea2bbc5fdd17f69a094d81a060f9140ed24a)

tags: added: in-stable-train
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.