Workaround for driver stats bug
Some drivers don't have a working stats cache as they should, and so they return an empty dictionary when we try to retrieve their cached stats by passing refresh=False. On such drivers is HPE's 3PAR. This patch works around this by checking returned value and call it again with refresh=True if the backend doesn't work as it should.
This commit is contained in:
parent
c1bbf1537c
commit
b89f2f2f99
|
@ -8,7 +8,7 @@ History
|
|||
- Bug fixes:
|
||||
|
||||
- Support MultiOpt configuration parameters
|
||||
|
||||
- Workaround for Cinder cached stats bug
|
||||
|
||||
0.3.4 (2019-01-26)
|
||||
------------------
|
||||
|
|
|
@ -38,6 +38,7 @@ from oslo_utils import importutils
|
|||
import urllib3
|
||||
|
||||
import cinderlib
|
||||
from cinderlib import exception
|
||||
from cinderlib import nos_brick
|
||||
from cinderlib import objects
|
||||
from cinderlib import persistence
|
||||
|
@ -46,6 +47,8 @@ from cinderlib import serialization
|
|||
|
||||
__all__ = ['setup', 'Backend']
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Backend(object):
|
||||
"""Representation of a Cinder Driver.
|
||||
|
@ -120,6 +123,18 @@ class Backend(object):
|
|||
|
||||
def stats(self, refresh=False):
|
||||
stats_data = self.driver.get_volume_stats(refresh=refresh)
|
||||
# TODO(geguileo): Remove this workaround for some drivers' bug that
|
||||
# don't have a working stats cache once they are fixed.
|
||||
if not refresh and not stats_data:
|
||||
LOG.warning('Refreshing cache to work around driver stats cache '
|
||||
'bug')
|
||||
stats_data = self.driver.get_volume_stats(refresh=True)
|
||||
|
||||
if not stats_data:
|
||||
msg = 'Driver not returning stats data'
|
||||
LOG.error(msg)
|
||||
raise exception.VolumeDriverException(message=msg)
|
||||
|
||||
# Fill pools for legacy driver reports
|
||||
if stats_data and 'pools' not in stats_data:
|
||||
pool = stats_data.copy()
|
||||
|
|
|
@ -21,6 +21,7 @@ VolumeNotFound = exception.VolumeNotFound
|
|||
SnapshotNotFound = exception.SnapshotNotFound
|
||||
ConnectionNotFound = exception.VolumeAttachmentNotFound
|
||||
InvalidVolume = exception.InvalidVolume
|
||||
VolumeDriverException = exception.VolumeDriverException
|
||||
|
||||
|
||||
class InvalidPersistence(Exception):
|
||||
|
|
Loading…
Reference in New Issue