Bug #33990
openForeman shouldn't reject valid volume attributes with "VM volume attributes are not set properly"
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=2024093
Description of problem:
In BZ#1813986 it was reported, that passing "size_gb: <an array>" of volumes_attributes to the compute_resources API will lead to an ISE, and it was fixed by checking that all parameters in "volumes_attributes" are strings (see https://github.com/theforeman/foreman/pull/7873).
This breaks perfectly valid requests that pass "size_gb: 50" (so an Integer) instead of "size_gb: '50'".
Additionally, the request was for a "Meaningful error message, like "Incorrect value of argument 'size_gb'"", but the current implementation just throws "VM volume attributes are not set properly" which neither indicates which volume attribute is wrong, neither what is wrong about it.
I would consider this a (albeit small) regression in Satellite 6.9 (as this is the first version shipping this code change).
Version-Release number of selected component (if applicable):
Satellite 6.9.7 (but really, anything that's based on Foreman 2.3 or newer)
How reproducible:
100%
Steps to Reproduce:
1. run the following Ansible playbook:
---
- hosts: localhost
tasks:
- name: Create compute profiles
redhat.satellite.compute_profile:
username: "admin"
password: "changeme"
server_url: https://satellite.example.com
name: test
compute_attributes:
- compute_resource: rhevm1
vm_attrs:
volumes_attributes:
0:
size_gb: 50
Actual results:
fatal: [satellite.example.com]: FAILED! => changed=false
error:
message: 'ERF42-2471 [Foreman::Exception]: VM volume attributes are not set properly'
msg: 'Error while performing create on compute_attributes: 500 Server Error: Internal Server Error'
Expected results:
It to work.
Or at least give a hint what's wrong.
Additional info:
- I think the API should accept both, Strings and Integers (and probably Booleans?), and only throw an error for other types. And then the error should say which entry is wrong and what it should look like to be valid.
- In a perfect world, this would be expressed an an Apipie validation in the APIdoc, but I think we don't document possible volumes_attributes at all in the apidoc :(
Updated by Tomer Brisker over 3 years ago
- Subject changed from Satellite shouldn't reject valid volume attributes with "VM volume attributes are not set properly" to Foreman shouldn't reject valid volume attributes with "VM volume attributes are not set properly"