exception when running 'watcher service list'
We have two controllers as HA in our OpenStack environment. There are watcher-applier and watcher-decision-engine in each controller. So there are two same name in the services table. In this case, the objects.Service.get_by_name(context, name) will trigger exception of MultipleResultsFound. We should use objects.Service.get(context, id) replace of objects.Service.get_by_name(context, name). Change-Id: Ic3ce784590d6c2a648cb3b28299744deed281332 Closes-Bug: #1674196
This commit is contained in:
@@ -56,8 +56,8 @@ class Service(base.APIBase):
|
||||
def _get_status(self):
|
||||
return self._status
|
||||
|
||||
def _set_status(self, name):
|
||||
service = objects.Service.get_by_name(pecan.request.context, name)
|
||||
def _set_status(self, id):
|
||||
service = objects.Service.get(pecan.request.context, id)
|
||||
last_heartbeat = (service.last_seen_up or service.updated_at
|
||||
or service.created_at)
|
||||
if isinstance(last_heartbeat, six.string_types):
|
||||
@@ -108,7 +108,7 @@ class Service(base.APIBase):
|
||||
for field in fields:
|
||||
self.fields.append(field)
|
||||
setattr(self, field, kwargs.get(
|
||||
field if field != 'status' else 'name', wtypes.Unset))
|
||||
field if field != 'status' else 'id', wtypes.Unset))
|
||||
|
||||
@staticmethod
|
||||
def _convert_with_links(service, url, expand=True):
|
||||
|
||||
Reference in New Issue
Block a user