Disable debug logs in superuser panel when under multiple instances

They don't work anyway (since logs will be loaded from random instances), so we just disable them
This commit is contained in:
Joseph Schorr 2017-05-24 14:34:29 -04:00
parent c55c233f1f
commit 9518f1d045
3 changed files with 41 additions and 18 deletions

View file

@ -3,6 +3,7 @@
import logging import logging
import os import os
import string import string
import socket
import pathvalidate import pathvalidate
@ -72,6 +73,7 @@ class SuperUserGetLogsForService(ApiResource):
abort(400) abort(400)
return { return {
'instance': socket.gethostname(),
'logs': '\n'.join(logs) 'logs': '\n'.join(logs)
} }
@ -91,6 +93,7 @@ class SuperUserSystemLogServices(ApiResource):
""" List the system logs for the current system. """ """ List the system logs for the current system. """
if SuperUserPermission().can(): if SuperUserPermission().can():
return { return {
'instance': socket.gethostname(),
'services': list(get_services()) 'services': list(get_services())
} }
@ -900,7 +903,7 @@ class SuperUserCustomCertificate(ApiResource):
abort(400) abort(400)
logger.debug('Saving custom certificate %s', certpath) logger.debug('Saving custom certificate %s', certpath)
cert_full_path = config_provider.get_volume_path(EXTRA_CA_DIRECTORY, certpath) cert_full_path = config_provider.get_volume_path(EXTRA_CA_DIRECTORY, certpath)
config_provider.save_volume_file(cert_full_path, uploaded_file) config_provider.save_volume_file(cert_full_path, uploaded_file)
logger.debug('Saved custom certificate %s', certpath) logger.debug('Saved custom certificate %s', certpath)

View file

@ -18,10 +18,12 @@
// Monitor any user changes and place the current user into the scope. // Monitor any user changes and place the current user into the scope.
UserService.updateUserIn($scope); UserService.updateUserIn($scope);
$scope.multipleInstances = false;
$scope.configStatus = null; $scope.configStatus = null;
$scope.requiresRestart = null; $scope.requiresRestart = null;
$scope.logsCounter = 0; $scope.logsCounter = 0;
$scope.changeLog = null; $scope.changeLog = null;
$scope.logsInstance = null;
$scope.debugServices = null; $scope.debugServices = null;
$scope.debugLogs = null; $scope.debugLogs = null;
$scope.pollChannel = null; $scope.pollChannel = null;
@ -83,6 +85,13 @@
}); });
ApiService.getSystemLogs(null, params, /* background */true).then(function(resp) { ApiService.getSystemLogs(null, params, /* background */true).then(function(resp) {
if ($scope.logsInstance != null && $scope.logsInstance != resp['instance']) {
$scope.multipleInstances = true;
callback(false);
return;
}
$scope.logsInstance = resp['instance'];
$scope.debugLogs = resp['logs']; $scope.debugLogs = resp['logs'];
callback(true); callback(true);
}, errorHandler); }, errorHandler);
@ -96,6 +105,13 @@
$scope.debugService = null; $scope.debugService = null;
ApiService.listSystemLogServices().then(function(resp) { ApiService.listSystemLogServices().then(function(resp) {
if ($scope.logsInstance != null && $scope.logsInstance != resp['instance']) {
$scope.multipleInstances = true;
callback(false);
return;
}
$scope.logsInstance = resp['instance'];
$scope.debugServices = resp['services']; $scope.debugServices = resp['services'];
}, ApiService.errorDisplay('Cannot load system logs. Please contact support.')) }, ApiService.errorDisplay('Cannot load system logs. Please contact support.'))
}; };

View file

@ -87,27 +87,31 @@
<!-- Debugging tab --> <!-- Debugging tab -->
<cor-tab-pane id="debug"> <cor-tab-pane id="debug">
<div class="cor-loader" ng-show="!debugServices"></div> <div class="co-alert co-alert-warning" ng-show="multipleInstances">
Debug logs cannot be displayed as <span class="registry-name"></span> is running under multiple containers. To retrieve logs, please use your implementation's custom configured logging solution.
</div>
<div ng-show="!multipleInstances">
<div class="cor-loader" ng-show="!debugServices"></div>
<div role="tabpanel" ng-show="debugServices">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ng-repeat="service in debugServices"
ng-class="debugService == service ? 'active' : ''">
<a ng-click="viewSystemLogs(service)">{{ service }}</a>
</li>
</ul>
<div role="tabpanel" ng-show="debugServices"> <div class="system-log-download-panel" ng-if="!debugService">
<!-- Nav tabs --> Select a service above to view its local logs
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ng-repeat="service in debugServices"
ng-class="debugService == service ? 'active' : ''">
<a ng-click="viewSystemLogs(service)">{{ service }}</a>
</li>
</ul>
<div class="system-log-download-panel" ng-if="!debugService"> <div>
Select a service above to view its local logs <a class="btn btn-primary" href="/systemlogsarchive?_csrf_token={{ csrf_token }}" ng-safenewtab>
<i class="fa fa-download fa-lg" style="margin-right: 4px;"></i> Download All Local Logs (.tar.gz)
<div> </a>
<a class="btn btn-primary" href="/systemlogsarchive?_csrf_token={{ csrf_token }}" ng-safenewtab> </div>
<i class="fa fa-download fa-lg" style="margin-right: 4px;"></i> Download All Local Logs (.tar.gz)
</a>
</div> </div>
<div class="cor-log-box" logs="debugLogs" ng-show="debugService"></div>
</div> </div>
<div class="cor-log-box" logs="debugLogs" ng-show="debugService"></div>
</div> </div>
</cor-tab-pane> </cor-tab-pane>