salt-cloud with lxc driver add odd data in output
Description of Issue/Question
salt-cloud add odd data with lxc driver. It should not be there. You can not control output format for that data - could be issue if you parse output.
# salt-cloud -Q
lab-deb9-cloud01:
True
lab-deb9-cloud02:
True
lab-deb9-cloud01:
True
lab-deb9-cloud01:
True
lab-deb9-cloud02:
True
lab-deb9-cloud02:
True
lab-deb9-cloud01:
----------
frozen:
----------
running:
----------
stopped:
----------
test-container01:
----------
config:
/var/lib/lxc/test-container01/config
ips:
ipv4_ips:
ipv6_ips:
nics:
|_
----------
type:
empty
private_ips:
private_ipv4_ips:
private_ipv6_ips:
public_ips:
public_ipv4_ips:
public_ipv6_ips:
rootfs:
/var/lib/lxc/test-container01/rootfs
size:
None
state:
stopped
lab-deb9-cloud02:
----------
frozen:
----------
running:
----------
stopped:
----------
test-container02:
----------
config:
/var/lib/lxc/test-container02/config
ips:
ipv4_ips:
ipv6_ips:
nics:
|_
----------
type:
empty
private_ips:
private_ipv4_ips:
private_ipv6_ips:
public_ips:
public_ipv4_ips:
public_ipv6_ips:
rootfs:
/var/lib/lxc/test-container02/rootfs
size:
None
state:
stopped
lab-deb9-cloud01:
----------
lxc:
----------
test-container01:
----------
id:
test-container01
image:
None
name:
test-container01
private_ips:
public_ips:
size:
None
state:
stopped
lab-deb9-cloud02:
----------
lxc:
----------
test-container02:
----------
id:
test-container02
image:
None
name:
test-container02
private_ips:
public_ips:
size:
None
state:
stopped
# salt-cloud -Q --out json
lab-deb9-cloud01:
True
lab-deb9-cloud02:
True
lab-deb9-cloud01:
True
lab-deb9-cloud01:
True
lab-deb9-cloud02:
True
lab-deb9-cloud02:
True
lab-deb9-cloud01:
----------
frozen:
----------
running:
----------
stopped:
----------
test-container01:
----------
config:
/var/lib/lxc/test-container01/config
ips:
ipv4_ips:
ipv6_ips:
nics:
|_
----------
type:
empty
private_ips:
private_ipv4_ips:
private_ipv6_ips:
public_ips:
public_ipv4_ips:
public_ipv6_ips:
rootfs:
/var/lib/lxc/test-container01/rootfs
size:
None
state:
stopped
lab-deb9-cloud02:
----------
frozen:
----------
running:
----------
stopped:
----------
test-container02:
----------
config:
/var/lib/lxc/test-container02/config
ips:
ipv4_ips:
ipv6_ips:
nics:
|_
----------
type:
empty
private_ips:
private_ipv4_ips:
private_ipv6_ips:
public_ips:
public_ipv4_ips:
public_ipv6_ips:
rootfs:
/var/lib/lxc/test-container02/rootfs
size:
None
state:
stopped
{
"lab-deb9-cloud01": {
"lxc": {
"test-container01": {
"name": "test-container01",
"image": null,
"state": "stopped",
"private_ips": [],
"public_ips": [],
"id": "test-container01",
"size": null
}
}
},
"lab-deb9-cloud02": {
"lxc": {
"test-container02": {
"name": "test-container02",
"image": null,
"state": "stopped",
"private_ips": [],
"public_ips": [],
"id": "test-container02",
"size": null
}
}
}
}
Setup
# cat /etc/salt/cloud.providers.d/lxc.conf
lab-deb9-cloud01:
target: lab-deb9-cloud01
driver: lxc
lab-deb9-cloud02:
target: lab-deb9-cloud02
driver: lxc
Steps to Reproduce Issue
Use configuration above and run salt-cloud -Q | salt-cloud -F | deploy new node
Versions Report
# salt-cloud -V
Salt Version:
Salt: 2017.7.2
Dependency Versions:
Apache Libcloud: 1.5.0
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.5.3
docker-py: Not Installed
gitdb: 2.0.0
gitpython: 2.1.1
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: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.13 (default, Jan 19 2017, 14:48:08)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 16.0.2
RAET: Not Installed
smmap: 2.0.1
timelib: Not Installed
Tornado: 4.4.3
ZMQ: 4.2.1
System Versions:
dist: debian 9.1
locale: UTF-8
machine: x86_64
release: 4.9.0-4-amd64
system: Linux
version: debian 9.1
Yes, this is because the lxc cloud driver uses the lxc runner, which prints out data for some reason. If you remove the print statements from the runner or change them to log messages, and put it in /srv/salt/_runners/ you can remove the data. (if you do this, I would love to see a PR)
It is something that I would like to fix, but it isn't high on the list of things we need to do.
@gtmanfred Thanks for reply.
After a quick glance at lxc runner I did not find print statement which produce such output. I think root case of that issue has another nature. Then we create client and runner objects we use master config and do not take into account salt-cloud cli options. https://github.com/saltstack/salt/blob/3c24edd6a5f9ec11530843c704df316b59dc5365/salt/cloud/clouds/lxc.py#L152 https://github.com/saltstack/salt/blob/3c24edd6a5f9ec11530843c704df316b59dc5365/salt/cloud/clouds/lxc.py#L153
I think that we must suppress messages from that objects and use "quiet" output for them. That fix looks trivial, I'm going submit PR.
Awesome!
Thanks for the PR! Daniel