Don't update the state of a scope when no data was collected

This makes the worker return instead of raising NoDataCollected
when an exception occurs during collection.

Before this patch, a NoDataCollected exception was raised when a collect
exception occured. This caused the worker to update the collect state and
to process the next period, leading to missing data in the storage backend.
With this patch, the collect state is not updated anymore.

Change-Id: I0f7c6d6e4cdc28ad6245b863d396c4f9403de380
Story: 2003828
Task: 26761
Task: 26763
This commit is contained in:
Luka Peschke 2018-10-29 11:18:43 +01:00
parent 7778986c3a
commit 7881c15093
1 changed files with 7 additions and 2 deletions

View File

@ -202,14 +202,19 @@ class Worker(BaseWorker):
except Exception as e:
LOG.warning(
'[%(scope_id)s] Error while collecting metric '
'%(metric)s: %(error)s',
'%(metric)s: %(error)s. Retrying on next '
'collection cycle.',
{
'scope_id': self._tenant_id,
'metric': metric,
'error': e,
},
)
raise collector.NoDataCollected('', metric)
# FIXME(peschk_l): here we just exit, and the
# collection will be retried during the next collect
# cycle. In the future, we should implement a retrying
# system in workers
return
except collector.NoDataCollected:
LOG.info(
'[{}] No data collected for metric {} '