Fix internal server error if all volumes are in other projects

This addresses the situation where all volumes are in another project
and details can't be fetched.   Before this patch, horizon would return
an internal server error but with this patch, an error will be returned
instead .

Change-Id: Id0522c884700dc2d005a4a665256a8c5e63da741
Closes-bug: #1971143
This commit is contained in:
David Hill 2025-03-26 10:10:49 -04:00
parent eb51c5d2fc
commit 1221d35a56

@ -37,7 +37,15 @@ class OverviewTab(tabs.Tab):
def get_context_data(self, request):
instance = self.tab_group.kwargs['instance']
if instance.volumes and not instance.image:
try:
volumes = instance.volumes
except AttributeError:
volume = None
volumes = None
exceptions.handle(self.request,
_('Failed to get attached volumes. Make sure'
' they are accessible from this project.'))
if volumes and not instance.image:
try:
volume = api.cinder.volume_get(
self.request, volume_id=instance.volumes[0].volumeId)