Bug 1400226

Summary: Fix CommandsFactory logging to show original cause of the issue
Product: [oVirt] ovirt-engine Reporter: Martin Mucha <mmucha>
Component: BLL.InfraAssignee: Miroslava Voglova <mvoglova>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Stehlik <pstehlik>
Severity: low Docs Contact:
Priority: unspecified    
Version: 4.1.0CC: bugs, mperina, oourfali
Target Milestone: ovirt-4.2.0Keywords: CodeChange
Target Release: 4.2.0Flags: rule-engine: ovirt-4.2+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-20 11:01:14 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:

Description Martin Mucha 2016-11-30 17:24:28 UTC
Description of problem:

In code, we often swallow exceptions. There isn't any benefit (know to me), to do so.


Example from CommandsFactory:

catch (Exception ex) {
            log.error("An exception has occurred while trying to create a command object for command '{}' with parameters '{}': {}",
                    action.name(),
                    parameters,
                    ex.getMessage());
            log.debug("Exception", ex);
            return null;
        }

which will print this into log:

ERROR [org.ovirt.engine.core.bll.CommandsFactory] (default task-45) [0cf7f066-8328-4d77-a35f-dac2d37f058b] An exception has occurred while trying to create a command object for command 'RunVm' with parameters 'RunVmParams:{commandId='0625b1bb-8924-48eb-aa08-84e10f97fbb8', user='null', commandType='Unknown', vmId='43f269c7-5341-41de-894b-7205fbc23a3b'}': WELD-000049: Unable to invoke protected final void org.ovirt.engine.core.bll.CommandBase.postConstruct() on org.ovirt.engine.core.bll.RunVmCommand@55495ef8


Exception: java.lang.NullPointerException
	at org.ovirt.engine.core.bll.NestedCommandFactory.createWrappedCommand(NestedCommandFactory.java:24) [bll.jar:]
	at org.ovirt.engine.core.bll.PrevalidatingMultipleActionsRunner.initCommandsAndReturnValues(PrevalidatingMultipleActionsRunner.java:91) [bll.jar:]
…

which is both totally irrelevant and without problem. One has to enter debugging session to find out:

Caused by: org.postgresql.util.PSQLException: The column name pass_discard was not found in this ResultSet.

————————————————
Intent of this code is totally misleaded. It does not make logs any shorter, and instead of logging causing exception as ERROR, we log as error something which is totally fine. Every such:

log.error
log.debug
swallow

should disappear from code as it severely damages our logs.

Comment 1 Pavel Stehlik 2017-08-30 12:07:38 UTC
CodeChange - nothing for QE.

Comment 2 Sandro Bonazzola 2017-12-20 11:01:14 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.