Fix EndpointSpec KeyError. (#637) (#638)

(cherry picked from commit 748d619fb2)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2023-05-26 21:20:18 +02:00 committed by GitHub
parent c68d90de76
commit c31fb79755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- "docker_swarm_info - if ``service=true`` is used, do not crash when a service without an endpoint spec is encountered (https://github.com/ansible-collections/community.docker/issues/636, https://github.com/ansible-collections/community.docker/pull/637)."

View File

@ -323,7 +323,7 @@ class DockerSwarmManager(DockerBaseClass):
# Number of replicas have to be updated in calling method or may be left as None # Number of replicas have to be updated in calling method or may be left as None
object_essentials['Replicas'] = None object_essentials['Replicas'] = None
object_essentials['Image'] = item['Spec']['TaskTemplate']['ContainerSpec']['Image'] object_essentials['Image'] = item['Spec']['TaskTemplate']['ContainerSpec']['Image']
if 'Ports' in item['Spec']['EndpointSpec']: if item['Spec'].get('EndpointSpec') and 'Ports' in item['Spec']['EndpointSpec']:
object_essentials['Ports'] = item['Spec']['EndpointSpec']['Ports'] object_essentials['Ports'] = item['Spec']['EndpointSpec']['Ports']
else: else:
object_essentials['Ports'] = [] object_essentials['Ports'] = []