Bug 1508023

Summary: NPE when adding fence agent through REST API using nonexistent host UUID
Product: [oVirt] ovirt-engine Reporter: Petr Matyáš <pmatyas>
Component: BLL.InfraAssignee: Eli Mesika <emesika>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Matyáš <pmatyas>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.2.0CC: bugs, mperina, oourfali, pmatyas
Target Milestone: ovirt-4.2.0Keywords: AutomationBlocker, Regression
Target Release: ---Flags: rule-engine: ovirt-4.2+
rule-engine: blocker+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-20 11:39:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
engine log none

Description Petr Matyáš 2017-10-31 17:25:54 UTC
Created attachment 1346011 [details]
engine log

Description of problem:
Adding fence agent through REST API fails with either 500 [General command validation failure.] or 400 [Internal Engine Error] and a huge NPE:
2017-10-31 19:15:38,117+02 ERROR [org.ovirt.engine.core.bll.AddFenceAgentCommand] (default task-32) [21370495-2ddd-49f2-b0ed-5508a8cbb
6ff] Error during ValidateFailure.: java.lang.NullPointerException
        at org.ovirt.engine.core.bll.AddFenceAgentCommand.validate(AddFenceAgentCommand.java:49) [bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.internalValidate(CommandBase.java:851) [bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.executeAction(CommandBase.java:405) [bll.jar:]
        at org.ovirt.engine.core.bll.executor.DefaultBackendActionExecutor.execute(DefaultBackendActionExecutor.java:13) [bll.jar:]
        at org.ovirt.engine.core.bll.Backend.runAction(Backend.java:509) [bll.jar:]
        at org.ovirt.engine.core.bll.Backend.runActionImpl(Backend.java:491) [bll.jar:]
        at org.ovirt.engine.core.bll.Backend.runAction(Backend.java:444) [bll.jar:]
        at sun.reflect.GeneratedMethodAccessor640.invoke(Unknown Source) [:1.8.0_144]
and few dozens extra lines you can find in the log

Version-Release number of selected component (if applicable):
ovirt-engine-4.2.0-0.0.master.20171030210714.gitef6bb9c.el7.centos.noarch

How reproducible:
always

Steps to Reproduce:
1. curl -v -u "$user@$domain:$password" -H "Content-type: application/xml" --insecure -X POST https://$fqdn/ovirt-engine/api/hosts/$host_id/fenceagents -d "<agent><address>$address</address><concurrent>false</concurrent><order>1</order><password>$password</password><type>ipmilan</type><username>$username</username></agent>"

Actual results:
500 Internal Server Error
<detail>[General command validation failure.]</detail>

Expected results:
new fence agent

Additional info:

Comment 1 Red Hat Bugzilla Rules Engine 2017-10-31 18:02:08 UTC
This bug report has Keywords: Regression or TestBlocker.
Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.

Comment 2 Eli Mesika 2017-11-07 10:52:33 UTC
Unable to reproduce on master :


curl -v -u "$user@$domain:$password" -H "Content-type: application/xml" --insecure -X POST $url/ovirt-engine/api/hosts/$host-uuid/fenceagents -d "<agent><address>$ip</address><concurrent>false</concurrent><order>1</order><password>$user-passwd</password><type>$type</type><username>$user</username></agent>"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to laptop.emesika.com (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'admin@internal'
> POST /ovirt-engine/api/hosts/6fbf21d8-1ada-4f7a-8ab9-3e4d61727f3d/fenceagents HTTP/1.1
> Host: laptop.emesika.com:8080
> Authorization: Basic YWRtaW5AaW50ZXJuYWw6YQ==
> User-Agent: curl/7.51.0
> Accept: */*
> Content-type: application/xml
> Content-Length: 189
> 
* upload completely sent off: 189 out of 189 bytes
< HTTP/1.1 201 Created
< Connection: keep-alive
< Location: http://laptop.emesika.com:8080/ovirt-engine/api/v4/ovirt-engine/api/hosts/6fbf21d8-1ada-4f7a-8ab9-3e4d61727f3d/fenceagents/b856934b-37ec-4117-930b-ff8b656daa34
< Content-Type: application/xml;charset=UTF-8
< Content-Length: 568
< Correlation-Id: e7286067-0bd0-45a7-9212-989c21e64ec6
< Date: Tue, 07 Nov 2017 10:47:55 GMT
< 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<agent href="/ovirt-engine/api/hosts/6fbf21d8-1ada-4f7a-8ab9-3e4d61727f3d/fenceagents/b856934b-37ec-4117-930b-ff8b656daa34" id="b856934b-37ec-4117-930b-ff8b656daa34">
    <address>XXXXXXXX</address>
    <encrypt_options>false</encrypt_options>
    <order>1</order>
    <password>XXXXXXX</password>
    <type>apc_snmp</type>
    <username>XXXXXX</username>
    <host href="/ovirt-engine/api/hosts/6fbf21d8-1ada-4f7a-8ab9-3e4d61727f3d" id="6fbf21d8-1ada-4f7a-8ab9-3e4d61727f3d"/>
</agent>
* Curl_http_done: called premature == 0
* Connection #0 to host laptop.emesika.com left intact

Comment 3 Petr Matyáš 2017-11-07 11:27:32 UTC
I just reproduced this on ovirt-engine-4.2.0-0.0.master.20171106202508.gitf5140b9.el7.centos.noarch with the same exception.

Comment 4 Eli Mesika 2017-11-08 09:33:24 UTC
From the log it seems that you are trying to execute the operation with an invalid host uuid , can you please verify that the uuid you are giving in the REST API call is valid 
Anyway, this is really a potential NPE in the code and I will fix that so in such cases you will get a "Host not found" message and not an NPE

Comment 5 Petr Matyáš 2017-11-08 10:52:44 UTC
Yeah, you were right, I didn't check the hosts uuid and it was wrong.
And yes, it would be nice to get some meaningful message and no NPE.

Comment 6 Petr Matyáš 2017-11-14 14:39:48 UTC
Verified on ovirt-engine-4.2.0-0.0.master.20171113223918.git25568c3.el7.centos.noarch

Comment 7 Sandro Bonazzola 2017-12-20 11:39:59 UTC
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.