salt: dockerng fails to decode JSON responses; believes the data are raw bytes

Description of Issue/Question

I am running Docker on my local machine. I am in the ‘docker’ group and can run the standard Docker ‘hello world’ from the command line. I am attempting to use dockerng to build/run an image given a Dockerfile sitting in a local directory. The Dockerfile in question is vanilla and runs just fine from the Docker CLI. I am not root, so I’m using salt-call --local state.sls <mystate> localconfig=<myconfig>. This fails with:

local:
----------
          ID: myuser/myimage:mytag
    Function: dockerng.image_present
      Result: False
     Comment: Encountered error building /home/bar/Dev/foo/build/foo.services.users as myuser/myimage:mytag: the JSON object must be str, not 'bytes'
     Started: 17:32:38.788996
    Duration: 264.832 ms
     Changes:   

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time: 264.832 ms

Setup

(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)

  • Using a Python 3.5 virtualenv
  • salt and docker-py installed from pip.
  • docker.io installed from apt-get on vanilla Ubuntu.
$ which python
/home/bar/Dev/foo/env/4/bin/python
$ python
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> docker.__version__
'1.10.6'
$ docker --version
Docker version 1.12.6, build 78d1802

mystate

# foo-docker/init.sls
myuser/myimage:mytag:
  dockerng.image_present:
    - build: {{ pillar['dockerfile_dir'] }}
    - force: True

myconfig

# /tmp/tmpm7k1ydjp
cachedir: /home/bar/Dev/foo/build/salt/._cache
file_roots:
  base: [/home/bar/Dev/foo/build/salt/root/states]
states_dir: /home/bar/Dev/foo/build/salt/root/states

Steps to Reproduce Issue

(Include debug logs if possible and relevant.)

/home/bar/Dev/foo/env/4/bin/salt-call --local \
   -l all \
   state.sls foo-docker \
   localconfig=/tmp/tmpm7k1ydjp \
   pillar="{'dockerfile_dir': '/home/bar/Dev/foo/build/foo.services.users'}"
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: dathon
[TRACE   ] The required configuration section, 'fluent_handler', was not found the in the configuration. Not loading the fluent logging handlers module.
[TRACE   ] None of the required configuration sections, 'logstash_udp_handler' and 'logstash_zmq_handler', were found in the configuration. Not loading the Logstash logging handlers module.
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Failed to open log file, do you have permission to write to /var/log/salt/minion?
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[TRACE   ] Loading core.hostname grain
[TRACE   ] Loading core.zmqversion grain
[TRACE   ] Loading core.id_ grain
[TRACE   ] Loading core.saltversion grain
[TRACE   ] Loading core.pythonpath grain
[TRACE   ] Loading core.saltversioninfo grain
[TRACE   ] Loading core.get_machine_id grain
[TRACE   ] Loading core.locale_info grain
[TRACE   ] Loading core.hwaddr_interfaces grain
[TRACE   ] Loading core.ip4_interfaces grain
[TRACE   ] Loading core.os_data grain
[TRACE   ] DMI system-uuid value /sys/firmware/dmi/tables/smbios_entry_point: Permission denied /dev/mem: Permission denied is an invalid UUID
[TRACE   ] DMI system-uuid value /sys/firmware/dmi/tables/smbios_entry_point: Permission denied /dev/mem: Permission denied is an invalid UUID
[TRACE   ] 'virt-what' could not be found in the following search path: '['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/games', '/usr/local/games', '/snap/bin']'
[DEBUG   ] Please install 'virt-what' to improve results of the 'virtual' grain.
[TRACE   ] 'virt-what' could not be found in the following search path: '['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/games', '/usr/local/games', '/snap/bin']'
[WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
[TRACE   ] Loading core.pythonexecutable grain
[TRACE   ] Loading core.ip6_interfaces grain
[TRACE   ] Loading core.path grain
[TRACE   ] Loading core.dns grain
[TRACE   ] Loading core.get_master grain
[TRACE   ] Loading core.ip_interfaces grain
[TRACE   ] Loading core.saltpath grain
[TRACE   ] Loading core.ip_fqdn grain
[TRACE   ] Loading core.pythonversion grain
[TRACE   ] Loading core.get_server_id grain
[TRACE   ] Loading core.append_domain grain
[TRACE   ] Device loop1 reports itself as an HDD
[TRACE   ] Device loop6 reports itself as an HDD
[TRACE   ] Device loop4 reports itself as an HDD
[TRACE   ] Device loop2 reports itself as an HDD
[TRACE   ] Device loop0 reports itself as an HDD
[TRACE   ] Device sda reports itself as an HDD
[TRACE   ] Device loop7 reports itself as an HDD
[TRACE   ] Device nvme0n1 reports itself as an SSD
[TRACE   ] Device loop5 reports itself as an HDD
[TRACE   ] Device loop3 reports itself as an HDD
[DEBUG   ] Determining pillar cache
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded state.sls
Cannot write to process directory. Do you have permissions to write to /var/cache/salt/minion/proc/20170628180527599456 ?
[DEBUG   ] LazyLoaded saltutil.is_running
[DEBUG   ] LazyLoaded grains.get
[DEBUG   ] Reading configuration from /tmp/tmpm7k1ydjp
[DEBUG   ] LazyLoaded roots.envs
[DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
[DEBUG   ] Updating roots fileserver cache
[TRACE   ] Lockfile /home/bar/Dev/foo/build/salt/._cache/file_lists/roots/.base.w created
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo-docker
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker relative path is foo-docker
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo relative path is foo
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/pyramid
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/pyramid is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/pyramid relative path is pyramid
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/top.sls
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/top.sls is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/top.sls relative path is top.sls
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo.sls
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo.sls is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo.sls relative path is foo.sls
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo-docker/build_template.sls
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/build_template.sls is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/build_template.sls relative path is foo-docker/build_template.sls
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo-docker/global_vars.jinja
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/global_vars.jinja is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/global_vars.jinja relative path is foo-docker/global_vars.jinja
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo-docker/build_template2.sls
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/build_template2.sls is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/build_template2.sls relative path is foo-docker/build_template2.sls
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo-docker/init.sls
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/init.sls is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/init.sls relative path is foo-docker/init.sls
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo-docker/init.bak
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/init.bak is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo-docker/init.bak relative path is foo-docker/init.bak
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/foo/init.sls
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo/init.sls is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/foo/init.sls relative path is foo/init.sls
[TRACE   ] roots: Processing /home/bar/Dev/foo/build/salt/root/states/pyramid/init.sls
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/pyramid/init.sls is not a link
[TRACE   ] roots: /home/bar/Dev/foo/build/salt/root/states/pyramid/init.sls relative path is pyramid/init.sls
[TRACE   ] Lockfile /home/bar/Dev/foo/build/salt/._cache/file_lists/roots/.base.w removed
[DEBUG   ] Determining pillar cache
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[INFO    ] Loading fresh modules for state activity
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] Could not find file 'salt://foo-docker.sls' in saltenv 'base'
[DEBUG   ] In saltenv 'base', looking at rel_path 'foo-docker/init.sls' to resolve 'salt://foo-docker/init.sls'
[DEBUG   ] In saltenv 'base', ** considering ** path '/home/bar/Dev/foo/build/salt/._cache/files/base/foo-docker/init.sls' to resolve 'salt://foo-docker/init.sls'
[DEBUG   ] compile template: /home/bar/Dev/foo/build/salt/._cache/files/base/foo-docker/init.sls
[DEBUG   ] Jinja search path: ['/home/bar/Dev/foo/build/salt/._cache/files/base']
[PROFILE ] Time (in seconds) to render '/home/bar/Dev/foo/build/salt/._cache/files/base/foo-docker/init.sls' using 'jinja' renderer: 0.012637138366699219
[DEBUG   ] Rendered data from file: /home/bar/Dev/foo/build/salt/._cache/files/base/foo-docker/init.sls:
myuser/myimage:mytag:
  dockerng.image_present:
    - build: /home/bar/Dev/foo/build/foo.services.users
    - force: True

[DEBUG   ] LazyLoaded config.get
[DEBUG   ] Results of YAML rendering: 
OrderedDict([('myuser/myimage:mytag', OrderedDict([('dockerng.image_present', [OrderedDict([('build', '/home/bar/Dev/foo/build/foo.services.users')]), OrderedDict([('force', True)])])]))])
[PROFILE ] Time (in seconds) to render '/home/bar/Dev/foo/build/salt/._cache/files/base/foo-docker/init.sls' using 'yaml' renderer: 0.019393205642700195
[DEBUG   ] Trying paths: <filter object at 0x7f5c30f259e8>
[DEBUG   ] No config file found
[DEBUG   ] http://localhost:None "GET /version HTTP/1.1" 200 206
[DEBUG   ] Attempting to run docker-py's "version" function with args=() and kwargs={}
[DEBUG   ] http://localhost:None "GET /v1.24/version HTTP/1.1" 200 206
[DEBUG   ] LazyLoaded dockerng.version
[DEBUG   ] LazyLoaded dockerng.image_present
[INFO    ] Running state [myuser/myimage:mytag] at time 18:05:27.850271
[INFO    ] Executing state dockerng.image_present for myuser/myimage:mytag
[DEBUG   ] Attempting to run docker-py's "images" function with args=() and kwargs={'all': False}
[DEBUG   ] http://localhost:None "GET /v1.24/images/json?only_ids=0&all=0 HTTP/1.1" 200 None
[DEBUG   ] Attempting to run docker-py's "build" function with args=() and kwargs={'quiet': False, 'nocache': False, 'rm': True, 'fileobj': None, 'tag': 'myuser/myimage:mytag', 'path': '/home/bar/Dev/foo/build/foo.services.users', 'dockerfile': None}
[DEBUG   ] Looking for auth config
[DEBUG   ] No auth config in memory - loading from filesystem
[DEBUG   ] Trying paths: <filter object at 0x7f5c30eee908>
[DEBUG   ] No config file found
[DEBUG   ] No auth config found
[DEBUG   ] http://localhost:None "POST /v1.24/build?nocache=False&pull=False&forcerm=False&q=False&t=myuser%2Fmyimage%3Amytag&rm=True HTTP/1.1" 200 None
[ERROR   ] Encountered error building /home/bar/Dev/foo/build/foo.services.users as myuser/myimage:mytag: the JSON object must be str, not 'bytes'
[INFO    ] Completed state [myuser/myimage:mytag] at time 18:05:28.097152 duration_in_ms=246.88
[DEBUG   ] File /home/bar/Dev/foo/build/salt/._cache/accumulator/140033937206912 does not exist, no need to cleanup.
[DEBUG   ] LazyLoaded config.option
[ERROR   ] Unable to write to SLS cache file /var/cache/salt/minion/sls.p. Check permission.
[ERROR   ] Unable to write to highstate cache file /var/cache/salt/minion/highstate.cache.p. Do you have permissions?
[DEBUG   ] LazyLoaded highstate.output
[TRACE   ] data = {'local': {'dockerng_|-myuser/myimage:mytag_|-myuser/myimage:mytag_|-image_present': {'name': 'myuser/myimage:mytag', 'changes': {}, 'comment': "Encountered error building /home/bar/Dev/foo/build/foo.services.users as myuser/myimage:mytag: the JSON object must be str, not 'bytes'", 'start_time': '18:05:27.850272', 'duration': '246.88 ms', 'result': False, '__id__': 'myuser/myimage:mytag', '__run_num__': 0}}}
local:
----------
          ID: myuser/myimage:mytag
    Function: dockerng.image_present
      Result: False
     Comment: Encountered error building /home/bar/Dev/foo/build/foo.services.users as myuser/myimage:mytag: the JSON object must be str, not 'bytes'
     Started: 18:05:27.850272
    Duration: 246.88 ms
     Changes:   

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time: 246.880 ms

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

# /home/bar/Dev/foo/env/4/bin/salt --versions-report
Salt Version:
           Salt: 2016.11.6
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: 1.10.6
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.9.6
        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: 3.5.3 (default, Jan 19 2017, 14:11:04)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.1
            ZMQ: 4.1.6
 
System Versions:
           dist: Ubuntu 17.04 zesty
        machine: x86_64
        release: 4.12.0-041200rc6-generic
         system: Linux
        version: Ubuntu 17.04 zesty

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 36 (20 by maintainers)

Commits related to this issue

Most upvoted comments

@brianthelion Thanks a lot for helping with getting this tested and verified. I’ll go ahead and close this.

@Ch3LL Pulled and will report back shortly…