new register-nodes does not accept ints for numeric input

Bug #1382275 reported by James Polley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
os-cloud-config
Fix Released
Critical
Ghe Rivero

Bug Description

Consider the following node definition:

    {
        "arch": "amd64",
        "cpu": 24,
        "disk": 800,
        "mac": [
            "12:34:56:78:90:AB"
        ],
        "memory": 49152,
        "pm_addr": "10.0.0.132",
        "pm_password": "password",
        "pm_type": "pxe_ipmitool",
        "pm_user": "admin"
    }

The previous incarnation of register-nodes would pipe this through jq, something like this:

    stack@bastion:/home/shared$ jq -r '"properties/cpus=" + (.cpu|tostring) + " properties/memory_mb=" + (.memory|tostring) + " properties/local_gb=" + (.disk|tostring) + " properties/cpu_arch=" + .arch' $NODE_JSON
    properties/cpus=24 properties/memory_mb=49152 properties/local_gb=800 properties/cpu_arch=amd64

Because jq explicitly converts the values to strings, the memory, cpu count, and disk figures could all be specified as integers or as strings.

The new register-nodes barfs on the same input:

        2014-10-17 01:28:35 - root - ERROR - Unexpected error during command execution
        Traceback (most recent call last):
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/os_cloud_config/cmd/register_nodes.py", line 74, in main
            blocking=True)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/os_cloud_config/nodes.py", line 249, in register_all_nodes
            blocking=blocking)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/os_cloud_config/nodes.py", line 203, in _update_or_register_ironic_node
            client.node.update(ironic_node.uuid, node_patch)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/ironicclient/v1/node.py", line 166, in update
            return self._update(self._path(node_id), patch)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/ironicclient/common/base.py", line 130, in _update
            resp, body = self.api.json_request(method, url, body=body)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/ironicclient/common/http.py", line 195, in json_request
            resp, body_iter = self._http_request(url, method, **kwargs)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/ironicclient/common/http.py", line 178, in _http_request
            error_json.get('debuginfo'), method, url)
        BadRequest: Invalid input for field/attribute value. Value: '49152'. Wrong type. Expected '<type 'unicode'>', got '<type 'int'>' (HTTP 400)

This is a backwards-compatibility issue, as peope who have existing nodes definitions that previously worked may find they do not work with the new register-nodes.

James Polley (tchaypo)
Changed in os-cloud-config:
status: New → Triaged
importance: Undecided → Critical
Ghe Rivero (ghe.rivero)
Changed in os-cloud-config:
assignee: nobody → Ghe Rivero (ghe.rivero)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to os-cloud-config (master)

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

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

Reviewed: https://review.openstack.org/129950
Committed: https://git.openstack.org/cgit/openstack/os-cloud-config/commit/?id=b3e1d87b13948b25792ec882e7be142d867ac243
Submitter: Jenkins
Branch: master

commit b3e1d87b13948b25792ec882e7be142d867ac243
Author: Ghe Rivero <email address hidden>
Date: Tue Oct 21 17:27:52 2014 +0200

    Allow register-node to accept int for input

    register-node used to pipe the nodes definition file through jq, which
    explicitly converts all int values to strings, but the new
    implementation doesn't do so, which is backward incompatible.

    Change-Id: Id5c5b56ccd73bdabe02eb24575e5b8c4dbcdb04b
    Closes-Bug: #1382275

Changed in os-cloud-config:
status: In Progress → Fix Committed
Changed in os-cloud-config:
status: Fix Committed → Fix Released
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.