Search in sources :

Example 1 with EntityPollingCommand

use of org.ovirt.engine.core.bll.storage.EntityPollingCommand in project ovirt-engine by oVirt.

the class HostJobCallback method handleUndeterminedJobStatus.

private HostJobStatus handleUndeterminedJobStatus(CommandBase<? extends HostJobCommandParameters> cmd, boolean jobsReportedByHost) {
    // If the command supports entity polling, we can use it in order to determine the status.
    if (isEntityPollingSupported(cmd)) {
        log.info("Command {} id: '{}': attempting to determine the job status by polling the entity.", cmd.getActionType(), cmd.getCommandId());
        HostJobStatus jobStatus = pollEntity(cmd);
        if (jobStatus != null) {
            return jobStatus;
        }
        // If the job status couldn't been detected using entity polling and the command supports job fencing, we
        // can attempt to fence the job - which means that the host will fail to execute it if it attempts to.
        // Note that we may attempt to perform the fencing even if the job failed in case we couldn't determine
        // the job status, that'll confirm the job failure.
        // 
        // Fencing the operation will usually be performed by executing an asynchronous fencing command on the
        // entity the job is supposed to be performed on.
        // If a fencing command was executed, the callback will wait for it to end and then will try to poll the
        // entity again (it'll be detected as a running child command). On synchronous fencing/no fencing we
        // will attempt to poll the entity again.
        ((EntityPollingCommand) cmd).attemptToFenceJob();
        return null;
    }
    if (((HostJobCommand) cmd).failJobWithUndeterminedStatus()) {
        log.error("Command {} id: '{}': failed to determine the actual job status, considering as failed as per" + " the command implementation", cmd.getActionType(), cmd.getCommandId());
        return HostJobStatus.failed;
    }
    // (as the command doesn't support entity polling - so we don't have any way to poll it).
    if (jobsReportedByHost) {
        log.error("Command {} id: '{}': entity polling isn't supported and the job isn't reported by the host," + "assuming it failed so that the command execution will end.", cmd.getActionType(), cmd.getCommandId());
        return HostJobStatus.failed;
    }
    // if we couldn't determine the job status, we'll retry to poll it.
    log.error("Command {} id: '{}': failed to determine the actual job status, will retry to poll the job soon", cmd.getActionType(), cmd.getCommandId());
    return null;
}
Also used : HostJobStatus(org.ovirt.engine.core.common.businessentities.HostJobInfo.HostJobStatus) EntityPollingCommand(org.ovirt.engine.core.bll.storage.EntityPollingCommand)

Aggregations

EntityPollingCommand (org.ovirt.engine.core.bll.storage.EntityPollingCommand)1 HostJobStatus (org.ovirt.engine.core.common.businessentities.HostJobInfo.HostJobStatus)1