Hide Forgot
Description of problem: I created new scheduling policy and wanted to attach it to cluster via REST, but operation failed with next error: <fault> <reason>Invalid value</reason> <detail> cpu_filter is not a member of SchedulingPolicyType. Possible values for SchedulingPolicyType are: evenly_distributed, power_saving, none, vm_evenly_distributed </detail> </fault> Version-Release number of selected component (if applicable): rhevm-3.5.0-0.26.el6ev.noarch How reproducible: Always Steps to Reproduce: 1. Create some custom scheduling policy via REST looks like: <scheduling_policy href= "/ovirt-engine/api/schedulingpolicies/18abab9b-a780-45c8-9727-3a925fda1703" id="18abab9b-a780-45c8-9727-3a925fda1703"> <name>cpu_filter</name> <link href= "/ovirt-engine/api/schedulingpolicies/18abab9b-a780-45c8-9727-3a925fda1703/filters" rel="filters"/> <link href= "/ovirt-engine/api/schedulingpolicies/18abab9b-a780-45c8-9727-3a925fda1703/weights" rel="weights"/> <link href= "/ovirt-engine/api/schedulingpolicies/18abab9b-a780-45c8-9727-3a925fda1703/balances" rel="balances"/> <link href= "/ovirt-engine/api/schedulingpolicies/18abab9b-a780-45c8-9727-3a925fda1703/clusters" rel="clusters"/> <locked>false</locked> <default_policy>false</default_policy> </scheduling_policy> 2. Try to attach scheduling to policy via REST: PUT to specific cluster <cluster> <scheduling_policy> <policy>cpu_filter</policy> </scheduling_policy> </cluster> 3. Actual results: <fault> <reason>Invalid value</reason> <detail> cpu_filter is not a member of SchedulingPolicyType. Possible values for SchedulingPolicyType are: evenly_distributed, power_saving, none, vm_evenly_distributed </detail> </fault> Expected results: scheduling policy attached to cluster without any error messages Additional info: Via UI all works fine
In the past scheduling policies used to be built-in entities, but recently they have been promoted to regular entities that the user can add/modify/delete. This means that the "policy" attribute can now be anything. But we didn't take this into account when we validate the value. However, take into account that the recommended way to reference a scheduling policy is using the "id" or "name" attributes, so you could add the scheduling policy to the cluster with requests like this (using the id): PUT /clusters/{cluster:id} <cluster> <scheduling_policy id="{schedulingpolicy:id}"/> </cluster> Or this (using the name): PUT /clusters/{cluster:id} <cluster> <scheduling_policy> <name>{schedulingpolicy:name}</name> </scheduling_policy> </cluster> Using the "policy" attribute should work at least for the old built-in scheduling policies. It is good if it works for the new ones as well, but not a must in my opinion. Anyhow, users (including the Python SDK) tend to update entities taking a complete entity and sending it again with all the attributes, not just the modified ones, so this problem will appear in many use cases. I think that we should at least remove the validation of the policy type that we have in SchedulingPolicyValidator, and it would be good to also make sure that the "policy" attribute is accepted like "id" and "name" are.
Thanks to Juan
Just checked the code and tried to reproduce the error. The property <policy/> does not exist anymore in 3.6. Only <name/> and <id/> can be used. The comment of Juan perfectly describes the situation in 3.5. <policy/> property can be used to add internal policies to the cluster, for custom policies <name/> or <id/> must be used.
Verified on rhevm-restapi-3.6.0.3-0.1.el6.noarch <cluster> <scheduling_policy> <name>test_policy</name> </scheduling_policy> </cluster> Works fine.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHEA-2016-0376.html