-
Notifications
You must be signed in to change notification settings - Fork 583
Can not update cluster node_count when the magnum API is running on python 3 #1458
Copy link
Copy link
Closed
Description
If the magnum API is running on python 3, when making a PATCH request to update node_count with a string as the value the API does not accept the value.
HTTP/1.1 400 Bad Request
Date: Wed, 20 Feb 2019 12:34:50 GMT
Server: Werkzeug/0.14.1 Python/3.5.2
OpenStack-API-Minimum-Version: container-infra 1.1
OpenStack-API-Maximum-Version: container-infra 1.6
OpenStack-API-Version: container-infra 1.6
vary: OpenStack-API-Version
Content-Type: application/json
Content-Length: 239
x-openstack-request-id: req-045c01a7-32ca-4f0d-b596-334a01d717f6
Connection: close
{"errors": [{"status": 400, "code": "client", "title": "Invalid input for field/attribute node_count", "detail": "Invalid input for field/attribute node_count. Value: '2'. unorderable types: str() < int()", "links": [], "request_id": ""}]}
The same request but without quotes around the node_count value in the request works properly:
HTTP/1.1 202 Accepted
Date: Wed, 20 Feb 2019 12:35:37 GMT
Server: Werkzeug/0.14.1 Python/3.5.2
OpenStack-API-Minimum-Version: container-infra 1.1
OpenStack-API-Maximum-Version: container-infra 1.6
OpenStack-API-Version: container-infra 1.6
vary: OpenStack-API-Version
Content-Length: 48
Content-Type: application/json
x-openstack-request-id: req-92b55b82-21cf-4a58-9903-f22b63e1b44e
Connection: close
{"uuid": "39a26b2c-74a5-4515-9bc8-9f8e71eba7b5"}
When the API is running on python 2 either way is accepted, it is only python 3 that is stricter.
The issue is that the cluster UpdateOpts only makes it possible to send a string:
gophercloud/openstack/containerinfra/v1/clusters/requests.go
Lines 138 to 142 in dcc6e84
| type UpdateOpts struct { | |
| Op UpdateOp `json:"op" required:"true"` | |
| Path string `json:"path" required:"true"` | |
| Value string `json:"value,omitempty"` | |
| } |
Providing an alternative UpdateOpts using an int as the value type works without any other modifications:
type UpdateOptsInt struct {
Op clusters.UpdateOp `json:"op" required:"true"`
Path string `json:"path" required:"true"`
Value int `json:"value,omitempty"`
}
func (opts UpdateOptsInt) ToClustersUpdateMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "")
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels