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

NAS-132742 / 24.10.1 / fix key collision in zpool.status (by yocalebo) #15047

Merged
merged 2 commits into from
Nov 26, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 26 additions & 27 deletions src/middlewared/middlewared/plugins/zfs_/pool_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,47 +95,46 @@ def status(self, data):
]
}
},
"evo": {
"spares": {},
"logs": {},
"dedup": {},
"special": {},
"l2cache": {},
"data": {
"/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec": {
"pool_name": "evo",
"disk_status": "ONLINE",
"disk_read_errors": 0,
"disk_write_errors": 0,
"disk_checksum_errors": 0,
"vdev_name": "stripe",
"vdev_type": "data",
"vdev_disks": [
"/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec"
]
}
"pools": {
"evo": {
"spares": {},
"logs": {},
"dedup": {},
"special": {},
"l2cache": {},
"data": {
"/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec": {
"pool_name": "evo",
"disk_status": "ONLINE",
"disk_read_errors": 0,
"disk_write_errors": 0,
"disk_checksum_errors": 0,
"vdev_name": "stripe",
"vdev_type": "data",
"vdev_disks": [
"/dev/disk/by-partuuid/d9cfa346-8623-402f-9bfe-a8256de902ec"
]
}
}
}
}
}
"""
pools = get_zpool_status(data.get('name'))

final = {'disks': dict()}
for pool_name, pool_info in pools.items():
final[pool_name] = dict()
final = {'disks': dict(), 'pools': dict()}
for pool_name, pool_info in get_zpool_status(data.get('name')).items():
final['pools'][pool_name] = dict()
# We need some normalization for data vdev here
pool_info['data'] = pool_info.get('vdevs', {}).get(pool_name, {}).get('vdevs', {})
for vdev_type in ('spares', 'logs', 'dedup', 'special', 'l2cache', 'data'):
vdev_members = pool_info.get(vdev_type, {})
if not vdev_members:
final[pool_name][vdev_type] = dict()
final['pools'][pool_name][vdev_type] = dict()
continue

info = self.status_impl(pool_name, vdev_type, vdev_members, **data)
# we key on pool name and disk id because
# this was designed, primarily, for the
# `webui.enclosure.dashboard` endpoint
final[pool_name][vdev_type] = info
final['pools'][pool_name][vdev_type] = info
final['disks'].update(info)

return final
220 changes: 111 additions & 109 deletions tests/api2/test_zpool_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,117 +104,119 @@ def get_pool_status(unused_disks, real_paths=False, replaced=False):
]
}
},
POOL_NAME: {
'spares': {
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}': {
'pool_name': POOL_NAME,
'disk_status': 'AVAIL' if not replaced else 'INUSE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'spares',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}'
]
}
},
'logs': {
f'{disk_uuid_mapping[unused_disks[3]] if not real_paths else unused_disks[3]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'logs',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[3]] if not real_paths else unused_disks[3]}'
]
}
},
'dedup': {
f'{disk_uuid_mapping[unused_disks[2]] if not real_paths else unused_disks[2]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'dedup',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[2]] if not real_paths else unused_disks[2]}'
]
}
},
'special': {
f'{disk_uuid_mapping[unused_disks[5]] if not real_paths else unused_disks[5]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'special',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[5]] if not real_paths else unused_disks[5]}'
]
}
},
'l2cache': {
f'{disk_uuid_mapping[unused_disks[0]] if not real_paths else unused_disks[0]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'l2cache',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[0]] if not real_paths else unused_disks[0]}'
]
}
},
'data': {
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'data',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}'
]
}
} if not replaced else {
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'spare-0',
'vdev_type': 'data',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}',
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}'
]
'pools': {
POOL_NAME: {
'spares': {
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}': {
'pool_name': POOL_NAME,
'disk_status': 'AVAIL' if not replaced else 'INUSE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'spares',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}'
]
}
},
'logs': {
f'{disk_uuid_mapping[unused_disks[3]] if not real_paths else unused_disks[3]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'logs',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[3]] if not real_paths else unused_disks[3]}'
]
}
},
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'spare-0',
'vdev_type': 'data',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}',
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}'
]
'dedup': {
f'{disk_uuid_mapping[unused_disks[2]] if not real_paths else unused_disks[2]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'dedup',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[2]] if not real_paths else unused_disks[2]}'
]
}
},
'special': {
f'{disk_uuid_mapping[unused_disks[5]] if not real_paths else unused_disks[5]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'special',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[5]] if not real_paths else unused_disks[5]}'
]
}
},
'l2cache': {
f'{disk_uuid_mapping[unused_disks[0]] if not real_paths else unused_disks[0]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'l2cache',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[0]] if not real_paths else unused_disks[0]}'
]
}
},
'data': {
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'stripe',
'vdev_type': 'data',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}'
]
}
} if not replaced else {
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'spare-0',
'vdev_type': 'data',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}',
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}'
]
},
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}': {
'pool_name': POOL_NAME,
'disk_status': 'ONLINE',
'disk_read_errors': 0,
'disk_write_errors': 0,
'disk_checksum_errors': 0,
'vdev_name': 'spare-0',
'vdev_type': 'data',
'vdev_disks': [
f'{disk_uuid_mapping[unused_disks[1]] if not real_paths else unused_disks[1]}',
f'{disk_uuid_mapping[unused_disks[4]] if not real_paths else unused_disks[4]}'
]
},
}
}
}
}
Expand Down