Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr/dashboard: additional fixes to block pages #20941

Merged
merged 3 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 26 additions & 4 deletions src/pybind/mgr/dashboard/controllers/tcmu_iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ def _get_rate(self, daemon_type, daemon_name, stat):
data = mgr.get_counter(daemon_type, daemon_name, stat)[stat]

if data and len(data) > 1:
return (data[-1][1] - data[-2][1]) / float(data[-1][0] - data[-2][0])
return 0
last_value = data[0][1]
last_time = data[0][0]
rates = []
for datum in data[1:]:
rates.append([datum[0], ((datum[1] - last_value) /
float(datum[0] - last_time))])
last_value = datum[1]
last_time = datum[0]
return rates
return [[0, 0]]

# pylint: disable=too-many-locals,too-many-nested-blocks
def list(self): # pylint: disable=unused-argument
Expand Down Expand Up @@ -64,19 +72,33 @@ def list(self): # pylint: disable=unused-argument
'tcmu-runner', service_id, perf_key)[perf_key] or
[[0, 0]])[-1][1] / 1000000000
if lock_acquired_time > image.get('optimized_since', 0):
image['optimized_daemon'] = hostname
image['optimized_since'] = lock_acquired_time
image['stats'] = {}
image['stats_history'] = {}
for s in ['rd', 'wr', 'rd_bytes', 'wr_bytes']:
perf_key = "{}{}".format(perf_key_prefix, s)
image['stats'][s] = self._get_rate(
'tcmu-runner', service_id, perf_key)[-1][1]
image['stats_history'][s] = self._get_rate(
'tcmu-runner', service_id, perf_key)
image['stats_history'][s] = mgr.get_counter(
'tcmu-runner', service_id, perf_key)[perf_key]
else:
daemon['non_optimized_paths'] += 1
image['non_optimized_paths'].append(hostname)

# clear up races w/ tcmu-runner clients that haven't detected
# loss of optimized path
for image in images.values():
optimized_daemon = image.get('optimized_daemon', None)
if optimized_daemon:
for daemon_name in image['optimized_paths']:
if daemon_name != optimized_daemon:
daemon = daemons[daemon_name]
daemon['optimized_paths'] -= 1
daemon['non_optimized_paths'] += 1
image['non_optimized_paths'].append(daemon_name)
image['optimized_paths'] = [optimized_daemon]

return {
'daemons': sorted(daemons.values(), key=lambda d: d['server_hostname']),
'images': sorted(images.values(), key=lambda i: ['id']),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from '@angular/core';

import { CellTemplate } from '../../../shared/enum/cell-template.enum';
import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe';
import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe';
import { DimlessPipe } from '../../../shared/pipes/dimless.pipe';
import { ListPipe } from '../../../shared/pipes/list.pipe';
import { RelativeDatePipe } from '../../../shared/pipes/relative-date.pipe';
Expand All @@ -21,7 +21,6 @@ export class IscsiComponent {

constructor(private tcmuIscsiService: TcmuIscsiService,
cephShortVersionPipe: CephShortVersionPipe,
dimlessBinaryPipe: DimlessBinaryPipe,
dimlessPipe: DimlessPipe,
relativeDatePipe: RelativeDatePipe,
listPipe: ListPipe) {
Expand Down Expand Up @@ -65,23 +64,25 @@ export class IscsiComponent {
},
{
name: 'Read Bytes',
prop: 'stats.rd_bytes',
pipe: dimlessBinaryPipe
prop: 'stats_history.rd_bytes',
cellTransformation: CellTemplate.sparkline
},
{
name: 'Write Bytes',
prop: 'stats.wr_bytes',
pipe: dimlessBinaryPipe
prop: 'stats_history.wr_bytes',
cellTransformation: CellTemplate.sparkline
},
{
name: 'Read Ops',
prop: 'stats.rd',
pipe: dimlessPipe
pipe: dimlessPipe,
cellTransformation: CellTemplate.perSecond
},
{
name: 'Write Ops',
prop: 'stats.wr',
pipe: dimlessPipe
pipe: dimlessPipe,
cellTransformation: CellTemplate.perSecond
},
{
name: 'A/O Since',
Expand All @@ -96,6 +97,11 @@ export class IscsiComponent {
this.tcmuIscsiService.tcmuiscsi().then((resp) => {
this.daemons = resp.daemons;
this.images = resp.images;
this.images.map((image) => {
image.stats_history.rd_bytes = image.stats_history.rd_bytes.map(i => i[1]);
image.stats_history.wr_bytes = image.stats_history.wr_bytes.map(i => i[1]);
return image;
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class MirroringComponent implements OnInit {
{ prop: 'id', name: 'ID', flexGrow: 2 },
{ prop: 'server_hostname', name: 'Hostname', flexGrow: 2 },
{
prop: 'server_hostname',
prop: 'version',
name: 'Version',
pipe: this.cephShortVersionPipe,
flexGrow: 2
Expand Down
76 changes: 56 additions & 20 deletions src/pybind/mgr/dashboard/tests/test_tcmu_iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,68 @@

mocked_servers = [{
'ceph_version': 'ceph version 13.0.0-5083- () mimic (dev)',
'hostname': 'ceph-dev',
'services': [{'id': 'a:b', 'type': 'tcmu-runner'}]
'hostname': 'ceph-dev1',
'services': [{'id': 'ceph-dev1:pool1/image1', 'type': 'tcmu-runner'}]
}, {
'ceph_version': 'ceph version 13.0.0-5083- () mimic (dev)',
'hostname': 'ceph-dev2',
'services': [{'id': 'ceph-dev2:pool1/image1', 'type': 'tcmu-runner'}]
}]

mocked_metadata = {
mocked_metadata1 = {
'ceph_version': 'ceph version 13.0.0-5083- () mimic (dev)',
'pool_name': 'pool1',
'image_name': 'image1',
'image_id': '42',
'optimized_since': 100.0,
'optimized_since': 1152121348,
}

mocked_metadata2 = {
'ceph_version': 'ceph version 13.0.0-5083- () mimic (dev)',
'pool_name': 'pool1',
'image_name': 'image1',
'image_id': '42',
'optimized_since': 0,
}

mocked_get_daemon_status = {
'lock_owner': 'true',
}

mocked_get_counter = {
'librbd-42-pool1-image1.lock_acquired_time': [[10000.0, 10000.0]],
mocked_get_counter1 = {
'librbd-42-pool1-image1.lock_acquired_time': [[1152121348 * 1000000000,
1152121348 * 1000000000]],
'librbd-42-pool1-image1.rd': [[0, 0], [1, 43]],
'librbd-42-pool1-image1.wr': [[0, 0], [1, 44]],
'librbd-42-pool1-image1.rd_bytes': [[0, 0], [1, 45]],
'librbd-42-pool1-image1.wr_bytes': [[0, 0], [1, 46]],
}

mocked_get_counter2 = {
'librbd-42-pool1-image1.lock_acquired_time': [[0, 0]],
'librbd-42-pool1-image1.rd': [],
'librbd-42-pool1-image1.wr': [],
'librbd-42-pool1-image1.rd_bytes': [],
'librbd-42-pool1-image1.wr_bytes': [],
}


def _get_counter(_daemon_type, daemon_name, _stat):
if daemon_name == 'ceph-dev1:pool1/image1':
return mocked_get_counter1
elif daemon_name == 'ceph-dev2:pool1/image1':
return mocked_get_counter2
return Exception('invalid daemon name')


class TcmuIscsiControllerTest(ControllerTestCase):

@classmethod
def setup_server(cls):
mgr.list_servers.return_value = mocked_servers
mgr.get_metadata.return_value = mocked_metadata
mgr.get_metadata.side_effect = [mocked_metadata1, mocked_metadata2]
mgr.get_daemon_status.return_value = mocked_get_daemon_status
mgr.get_counter.return_value = mocked_get_counter
mgr.get_counter.side_effect = _get_counter
mgr.url_prefix = ''
TcmuIscsi._cp_config['tools.authenticate.on'] = False # pylint: disable=protected-access

Expand All @@ -50,26 +79,33 @@ def test_list(self):
self._get('/api/test/tcmu')
self.assertStatus(200)
self.assertJsonBody({
'daemons': [{
'server_hostname': 'ceph-dev',
'version': 'ceph version 13.0.0-5083- () mimic (dev)',
'optimized_paths': 1, 'non_optimized_paths': 0}],
'daemons': [
{
'server_hostname': 'ceph-dev1',
'version': 'ceph version 13.0.0-5083- () mimic (dev)',
'optimized_paths': 1, 'non_optimized_paths': 0},
{
'server_hostname': 'ceph-dev2',
'version': 'ceph version 13.0.0-5083- () mimic (dev)',
'optimized_paths': 0, 'non_optimized_paths': 1}],
'images': [{
'device_id': 'b',
'device_id': 'pool1/image1',
'pool_name': 'pool1',
'name': 'image1',
'id': '42', 'optimized_paths': ['ceph-dev'],
'non_optimized_paths': [],
'optimized_since': 1e-05,
'id': '42',
'optimized_paths': ['ceph-dev1'],
'non_optimized_paths': ['ceph-dev2'],
'optimized_daemon': 'ceph-dev1',
'optimized_since': 1152121348,
'stats': {
'rd': 43.0,
'wr': 44.0,
'rd_bytes': 45.0,
'wr_bytes': 46.0},
'stats_history': {
'rd': [[0, 0], [1, 43]],
'wr': [[0, 0], [1, 44]],
'rd_bytes': [[0, 0], [1, 45]],
'wr_bytes': [[0, 0], [1, 46]]}
'rd': [[1, 43]],
'wr': [[1, 44]],
'rd_bytes': [[1, 45]],
'wr_bytes': [[1, 46]]}
}]
})