mirror of
https://github.com/ceph/ceph
synced 2025-04-01 23:02:17 +00:00
Merge pull request #24369 from p-na/fix-osd-error
mgr/dashboard: Fix error when clicking on newly created OSD Reviewed-by: Ricardo Marques <rimarques@suse.com> Reviewed-by: Volker Theile <vtheile@suse.com>
This commit is contained in:
commit
ac7a77149f
qa/tasks/mgr/dashboard
src/pybind/mgr/dashboard
controllers
frontend/src/app
ceph
cluster/osd/osd-details
performance-counter/table-performance-counter
shared/services
@ -25,8 +25,8 @@ class DashboardTestCase(MgrTestCase):
|
||||
CLIENTS_REQUIRED = 1
|
||||
CEPHFS = False
|
||||
|
||||
_session = None
|
||||
_resp = None
|
||||
_session = None # type: requests.sessions.Session
|
||||
_resp = None # type: requests.models.Response
|
||||
_loggedin = False
|
||||
_base_uri = None
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .helper import DashboardTestCase
|
||||
from .helper import DashboardTestCase, JObj
|
||||
|
||||
|
||||
class PerfCountersControllerTest(DashboardTestCase):
|
||||
@ -32,7 +32,6 @@ class PerfCountersControllerTest(DashboardTestCase):
|
||||
self.assertIn('unit', counter)
|
||||
self.assertIn('value', counter)
|
||||
|
||||
|
||||
def test_perf_counters_mon_get(self):
|
||||
mon = self.mons()[0]
|
||||
data = self._get('/api/perf_counters/mon/{}'.format(mon))
|
||||
@ -57,3 +56,18 @@ class PerfCountersControllerTest(DashboardTestCase):
|
||||
data = self._get('/api/perf_counters/osd/{}'.format(osd))
|
||||
self.assertStatus(200)
|
||||
self._validate_perf(osd, 'osd', data, allow_empty=False)
|
||||
|
||||
def test_perf_counters_not_found(self):
|
||||
osds = self.ceph_cluster.mon_manager.get_osd_dump()
|
||||
unused_id = int(list(map(lambda o: o['osd'], osds)).pop()) + 1
|
||||
|
||||
self._get('/api/perf_counters/osd/{}'.format(unused_id))
|
||||
self.assertStatus(404)
|
||||
schema = JObj(sub_elems={
|
||||
'status': str,
|
||||
'version': str,
|
||||
'detail': str,
|
||||
'traceback': str,
|
||||
})
|
||||
self.assertEqual(self._resp.json()['detail'], 'osd.{} not found'.format(unused_id))
|
||||
self.assertSchemaBody(schema)
|
||||
|
@ -1,6 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
|
||||
import cherrypy
|
||||
|
||||
from . import ApiController, RESTController
|
||||
from .. import mgr
|
||||
from ..security import Scope
|
||||
@ -12,7 +14,10 @@ class PerfCounter(RESTController):
|
||||
|
||||
def get(self, service_id):
|
||||
schema_dict = mgr.get_perf_schema(self.service_type, str(service_id))
|
||||
schema = schema_dict["{}.{}".format(self.service_type, service_id)]
|
||||
try:
|
||||
schema = schema_dict["{}.{}".format(self.service_type, service_id)]
|
||||
except KeyError as e:
|
||||
raise cherrypy.HTTPError(404, "{0} not found".format(e.message))
|
||||
counters = []
|
||||
|
||||
for key, value in sorted(schema.items()):
|
||||
|
@ -5,10 +5,15 @@
|
||||
</cd-table-key-value>
|
||||
</tab>
|
||||
<tab heading="Metadata">
|
||||
<cd-table-key-value *ngIf="osd.loaded"
|
||||
<cd-table-key-value *ngIf="osd.loaded && osd.details.osd_metadata; else noMetaData"
|
||||
(fetchData)="osd.autoRefresh()"
|
||||
[data]="osd.details.osd_metadata">
|
||||
</cd-table-key-value>
|
||||
<ng-template #noMetaData>
|
||||
<cd-warning-panel i18n>
|
||||
Metadata not available
|
||||
</cd-warning-panel>
|
||||
</ng-template>
|
||||
</tab>
|
||||
<tab heading="Performance counter">
|
||||
<cd-table-performance-counter *ngIf="osd.loaded"
|
||||
|
@ -32,7 +32,7 @@ export class OsdDetailsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.osdService.getDetails(this.osd.tree.id).subscribe((data: any) => {
|
||||
this.osdService.getDetails(this.osd.id).subscribe((data: any) => {
|
||||
this.osd.details = data;
|
||||
this.osd.histogram_failed = '';
|
||||
if (!_.isObject(data.histogram)) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
<cd-table [data]="counters"
|
||||
<cd-table *ngIf="counters; else warning"
|
||||
[data]="counters"
|
||||
[columns]="columns"
|
||||
columnMode="flex"
|
||||
[autoSave]="false"
|
||||
@ -7,3 +8,8 @@
|
||||
{{ row.value | dimless }} {{ row.unit }}
|
||||
</ng-template>
|
||||
</cd-table>
|
||||
<ng-template #warning>
|
||||
<cd-warning-panel i18n>
|
||||
Performance counters not available
|
||||
</cd-warning-panel>
|
||||
</ng-template>
|
||||
|
@ -53,10 +53,16 @@ export class TablePerformanceCounterComponent implements OnInit {
|
||||
}
|
||||
|
||||
getCounters() {
|
||||
this.performanceCounterService
|
||||
.get(this.serviceType, this.serviceId)
|
||||
.subscribe((resp: object[]) => {
|
||||
this.performanceCounterService.get(this.serviceType, this.serviceId).subscribe(
|
||||
(resp: object[]) => {
|
||||
this.counters = resp;
|
||||
});
|
||||
},
|
||||
(error) => {
|
||||
if (error.status === 404) {
|
||||
error.preventDefault();
|
||||
this.counters = null;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -82,16 +82,6 @@ describe('ApiInterceptorService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should redirect 404', (done) => {
|
||||
runRouterTest(
|
||||
{
|
||||
status: 404
|
||||
},
|
||||
[['/404']],
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('should show notification (error string)', function(done) {
|
||||
runNotificationTest(
|
||||
'foobar',
|
||||
|
@ -59,9 +59,6 @@ export class ApiInterceptorService implements HttpInterceptor {
|
||||
case 403:
|
||||
this.router.navigate(['/403']);
|
||||
break;
|
||||
case 404:
|
||||
this.router.navigate(['/404']);
|
||||
break;
|
||||
}
|
||||
|
||||
let timeoutId;
|
||||
|
Loading…
Reference in New Issue
Block a user