Prevent crash if Mode isn't present, which happens for Swarm jobs. (#1003) (#1004)

(cherry picked from commit 7583ea82ac)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2024-12-04 21:57:04 +01:00 committed by GitHub
parent 29c586c6fd
commit 4ab7733579
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- "docker_swarm_info - do not crash when finding Swarm jobs if ``services=true`` (https://github.com/ansible-collections/community.docker/issues/1003)."

View File

@ -270,7 +270,7 @@ class DockerSwarmManager(DockerBaseClass):
item_record = self.get_essential_facts_tasks(item)
elif docker_object == 'services':
item_record = self.get_essential_facts_services(item)
if item_record['Mode'] == 'Global':
if item_record.get('Mode') == 'Global':
item_record['Replicas'] = len(items)
items_list.append(item_record)