mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* consul: fixed bug in ConsulService when storing checks
* added changelog fragment
* typo
(cherry picked from commit 5a8422c8cb
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
5434d9217e
commit
31e622a0a3
2 changed files with 10 additions and 8 deletions
2
changelogs/fragments/4590-consul-fix-service-checks.yaml
Normal file
2
changelogs/fragments/4590-consul-fix-service-checks.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- consul - fixed bug where class ``ConsulService`` was overwriting the field ``checks``, preventing the addition of checks to a service (https://github.com/ansible-collections/community.general/pull/4590).
|
|
@ -411,7 +411,7 @@ class ConsulService(object):
|
||||||
self.address = address
|
self.address = address
|
||||||
self.port = port
|
self.port = port
|
||||||
self.tags = tags
|
self.tags = tags
|
||||||
self.checks = []
|
self._checks = []
|
||||||
if loaded:
|
if loaded:
|
||||||
self.id = loaded['ID']
|
self.id = loaded['ID']
|
||||||
self.name = loaded['Service']
|
self.name = loaded['Service']
|
||||||
|
@ -424,8 +424,8 @@ class ConsulService(object):
|
||||||
if self.port:
|
if self.port:
|
||||||
optional['port'] = self.port
|
optional['port'] = self.port
|
||||||
|
|
||||||
if len(self.checks) > 0:
|
if len(self._checks) > 0:
|
||||||
optional['check'] = self.checks[0].check
|
optional['check'] = self._checks[0].check
|
||||||
|
|
||||||
consul_api.agent.service.register(
|
consul_api.agent.service.register(
|
||||||
self.name,
|
self.name,
|
||||||
|
@ -435,13 +435,13 @@ class ConsulService(object):
|
||||||
**optional)
|
**optional)
|
||||||
|
|
||||||
def add_check(self, check):
|
def add_check(self, check):
|
||||||
self.checks.append(check)
|
self._checks.append(check)
|
||||||
|
|
||||||
def checks(self):
|
def checks(self):
|
||||||
return self.checks
|
return self._checks
|
||||||
|
|
||||||
def has_checks(self):
|
def has_checks(self):
|
||||||
return len(self.checks) > 0
|
return len(self._checks) > 0
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return (isinstance(other, self.__class__) and
|
return (isinstance(other, self.__class__) and
|
||||||
|
@ -459,8 +459,8 @@ class ConsulService(object):
|
||||||
data['port'] = self.port
|
data['port'] = self.port
|
||||||
if self.tags and len(self.tags) > 0:
|
if self.tags and len(self.tags) > 0:
|
||||||
data['tags'] = self.tags
|
data['tags'] = self.tags
|
||||||
if len(self.checks) > 0:
|
if len(self._checks) > 0:
|
||||||
data['check'] = self.checks[0].to_dict()
|
data['check'] = self._checks[0].to_dict()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue