[BUG]salt.modules.swarm.swarm_service_info crashes with no exposed ports
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue
When running swarm.swarm_service_info to retrieve docker service information about a service, the module returns an error if the service has no exposed ports (for example: if it's using host networking). The error references this line: https://github.com/saltstack/salt/blob/master/salt/modules/swarm.py#L259 and is as follows:
The minion function caused an exception: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1664, in _thread_return
return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
File "/usr/lib/python2.7/dist-packages/salt/executors/direct_call.py", line 12, in execute
return func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/swarm.py", line 259, in swarm_service_info
ports = dump['Spec']['EndpointSpec']['Ports']
KeyError: u'Ports'
Setup
Create a minion (called "minion" in this example) with a docker service on it (called "service" in this example) that uses host networking (or otherwise has no exposed ports)
Steps to Reproduce Issue
Run salt 'minion' swarm.swarm_service_info service_name='service'
Versions Report
Master:
Salt Version:
Salt: 2019.2.2
Dependency Versions:
cffi: 1.12.3
cherrypy: Not Installed
dateutil: 2.7.3
docker-py: Not Installed
gitdb: 2.0.5
gitpython: 2.1.11
ioflo: Not Installed
Jinja2: 2.9.4
libgit2: 0.26.8
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: 2.17
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: 0.26.4
Python: 2.7.16 (default, Apr 6 2019, 01:42:57)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.1.2
RAET: Not Installed
smmap: 2.0.5
timelib: Not Installed
Tornado: 5.1.1
ZMQ: 4.3.1
System Versions:
dist: debian 10.0
locale: UTF-8
machine: x86_64
release: 4.19.0-5-amd64
system: Linux
version: debian 10.0
Minion:
Salt Version:
Salt: 2019.2.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.5.3
docker-py: 4.1.0
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.9.4
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: 1.3.7
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 16.0.2
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.3
ZMQ: 4.2.1
System Versions:
dist: debian 9.9
locale: UTF-8
machine: x86_64
release: 4.9.0-9-amd64
system: Linux
version: debian 9.9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in salt/modules/swarm.py at the swarm_service_info entry point and the line referenced in the traceback. Reproduce the command with a Docker service using host networking or no exposed ports, then verify the function returns service information without raising an exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100