Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Fix to bugreport #684 and #693
Browse files Browse the repository at this point in the history
Fixes #684: Long logs aren't displayed
Fixes #693: bareos-webui generate error exception with certain messages
  • Loading branch information
fbergkemper committed Jan 31, 2017
1 parent 837d6a2 commit c3c7d6c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
8 changes: 4 additions & 4 deletions module/Job/src/Job/Controller/JobController.php
Expand Up @@ -153,17 +153,17 @@ public function detailsAction()

try {
$this->bsock = $this->getServiceLocator()->get('director');
$job = $this->getJobModel()->getJob($this->bsock, $jobid);
$joblog = $this->getJobModel()->getJobLog($this->bsock, $jobid);
//$job = $this->getJobModel()->getJob($this->bsock, $jobid);
//$joblog = $this->getJobModel()->getJobLog($this->bsock, $jobid);
$this->bsock->disconnect();
}
catch(Exception $e) {
echo $e->getMessage();
}

return new ViewModel(array(
'job' => $job,
'joblog' => $joblog,
//'job' => $job,
//'joblog' => $joblog,
'jobid' => $jobid
));
}
Expand Down
12 changes: 10 additions & 2 deletions module/Job/src/Job/Model/JobModel.php
Expand Up @@ -114,8 +114,16 @@ public function getJobLog(&$bsock=null, $id=null)
if(isset($bsock, $id)) {
$cmd = 'list joblog jobid='.$id.'';
$result = $bsock->send_command($cmd, 2, null);
$log = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $log['result']['joblog'];
if(preg_match('/Failed to send result as json. Maybe result message to long?/', $result)) {
//return false;
$error = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $error['result']['error'];
}
else {
$log = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $log['result']['joblog'];
}

}
else {
throw new \Exception('Missing argument.');
Expand Down
25 changes: 25 additions & 0 deletions module/Job/view/job/job/details.phtml
Expand Up @@ -109,6 +109,26 @@ $this->headTitle($title);
echo $this->headLink()->prependStylesheet($this->basePath() . '/css/datatables.min.css');
?>

<!-- modal-001 start -->
<div id="modal-001" class="modal fade modal-001" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel"><?php echo $this->translate("Failed to retrieve data from Bareos director"); ?></h4>
</div>
<div class="modal-body">
<p><?php echo $this->translate("Error message received from director:"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe the result message is too long?"); ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $this->translate("Close"); ?></button>
</div>
</div>
</div>
</div>
<!-- modal-001 end -->

<style>

td.details-control:after {
Expand Down Expand Up @@ -319,6 +339,11 @@ $(document).ready(function() {
$('#jobdetails tbody').on('mouseover', '#btn-1', function () {
$('[data-toggle="tooltip"]').tooltip();
});

$('#joblog').on('error.dt', function(e, settings, techNote, message) {
$("#modal-001").modal();
});

} );

</script>
Expand Down
2 changes: 1 addition & 1 deletion module/Job/view/job/job/index.phtml
Expand Up @@ -108,7 +108,7 @@ $this->headTitle($title);
<div class="modal-body">
<p><?php echo $this->translate("Please try to reduce the amount of data to display, e.g. reduce time period."); ?></p>
<p><?php echo $this->translate("Error message received from director:"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe result message to long?"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe the result message is too long?"); ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $this->translate("Close"); ?></button>
Expand Down

4 comments on commit c3c7d6c

@CHIP0K
Copy link

@CHIP0K CHIP0K commented on c3c7d6c Mar 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have applied this fix, but the error is still present.
OS: Debian 7
PHP 5.6.30
bareos-webui version: 17.1.3

An error occurred during execution; please try again later.
/var/www/bareos-webui/vendor/zendframework/zend-json/src/Json.php:68
Decoding failed: Syntax error

#0 /var/www/bareos-webui/module/Media/src/Media/Model/MediaModel.php(36): Zend\Json\Json::decode('{ "jsonrpc": "2...', 1)
#1 /var/www/bareos-webui/module/Media/src/Media/Controller/MediaController.php(63): Media\Model\MediaModel->getVolumes(Object(Bareos\BSock\BareosBSock))
#2 /var/www/bareos-webui/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(82): Media\Controller\MediaController->indexAction()
#3 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#4 /var/www/bareos-webui/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#5 /var/www/bareos-webui/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#6 /var/www/bareos-webui/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(118): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#7 /var/www/bareos-webui/vendor/zendframework/zend-mvc/src/DispatchListener.php(93): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#8 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#9 /var/www/bareos-webui/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#10 /var/www/bareos-webui/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#11 /var/www/bareos-webui/vendor/zendframework/zend-mvc/src/Application.php(314): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#12 /var/www/bareos-webui/public/index.php(24): Zend\Mvc\Application->run()
#13 {main}

@fbergkemper
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What result do you get in bconsole, when you execute the following commands?

.api 2
llist volumes

Is the json result well-formed?

@fbergkemper
Copy link
Contributor Author

@fbergkemper fbergkemper commented on c3c7d6c Apr 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, stupid me, this just fixes issues with long logs, sorry. Your case is probably related to a high number of volumes and the result of llist volumes/media can not be send by the director daemon because of its size, unfortunately this is currently a limitation of the director. I'm going to have a deeper look into it.

@CHIP0K
Copy link

@CHIP0K CHIP0K commented on c3c7d6c Apr 3, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.