Skip to content

Commit

Permalink
Fix EndpointSpec KeyError. (#637)
Browse files Browse the repository at this point in the history
(cherry picked from commit 748d619)
  • Loading branch information
felixfontein authored and patchback[bot] committed May 26, 2023
1 parent c68d90d commit 770171f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/637-swarm_info-endpoint_spec.yml
Original file line number Diff line number Diff line change
@@ -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)."
2 changes: 1 addition & 1 deletion plugins/modules/docker_swarm_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def get_essential_facts_services(item):
# Number of replicas have to be updated in calling method or may be left as None
object_essentials['Replicas'] = None
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']
else:
object_essentials['Ports'] = []
Expand Down

0 comments on commit 770171f

Please sign in to comment.