Add a detailed debug message in case of segment allocation fail
Added an extra detailed message in case of error in the partial segment allocation fail. This message should not be present in production. This message should help in the debugging of the related bug. Related-Bug: #2086602 Change-Id: I49b6e5f3be86c19e0a9e657ee6fe5f61c3b81bb3
This commit is contained in:
committed by
Rodolfo Alonso
parent
498b0258c5
commit
b7b7a31472
@@ -55,6 +55,15 @@ class SegmentAllocation(metaclass=abc.ABCMeta):
|
||||
query = query.order_by(rand_func())
|
||||
return query.first()
|
||||
|
||||
@classmethod
|
||||
def get_all_unallocated_segments(cls, context, **filters):
|
||||
with cls.db_context_reader(context):
|
||||
columns = set(dict(cls.db_model.__table__.columns))
|
||||
model_filters = {k: filters[k]
|
||||
for k in columns & set(filters.keys())}
|
||||
return context.session.query(cls.db_model).filter_by(
|
||||
allocated=False, **model_filters).all()
|
||||
|
||||
@classmethod
|
||||
def allocate(cls, context, **segment):
|
||||
with cls.db_context_writer(context):
|
||||
|
||||
@@ -156,6 +156,22 @@ class SegmentTypeDriver(BaseTypeDriver):
|
||||
raise db_exc.RetryRequest(
|
||||
exceptions.NoNetworkFoundInMaximumAllowedAttempts())
|
||||
|
||||
# NOTE(ralonsoh): this debug message is added to debug LP#2086602.
|
||||
# Once fixed, it won't be needed. This debug message should not be
|
||||
# released.
|
||||
LOG.debug('Partial segment allocation fail:')
|
||||
LOG.debug(' - Filters: %s', filters)
|
||||
LOG.debug(' - Non allocated segments:')
|
||||
for non_allocated_segment in (
|
||||
self.segmentation_obj.get_all_unallocated_segments(context,
|
||||
**filters)):
|
||||
LOG.debug(' - %s', non_allocated_segment)
|
||||
if directory.get_plugin(plugin_constants.NETWORK_SEGMENT_RANGE):
|
||||
LOG.debug(' - Network segment ranges:')
|
||||
for srange in ns_range.NetworkSegmentRange.get_objects(
|
||||
context.elevated()):
|
||||
LOG.debug(' - %s', srange)
|
||||
|
||||
@db_api.retry_db_errors
|
||||
def _delete_expired_default_network_segment_ranges(self):
|
||||
ctx = context.get_admin_context()
|
||||
|
||||
Reference in New Issue
Block a user