saltstack / saltstack/salt

docker.image_present fails on state.pkg call when building with SLS

Open
#55,692 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

During a run of docker.image_present using the "sls" option to build from another SLS file, it fails when calling "state.pkg" on the file "salt_state.tgz".

Setup

SLS files (this is just a contrived example for demonstration)
sls_build/init.sls

Build image with SLS:
  docker_image.present:
    - name: sls_build
    - sls: sls_build.image_build
    - tag: latest
    - base: 'centos:7'
    - pillar:
        symlinks:
          - /usr/local/bin/a
          - /usr/local/bin/b
        target: /usr/bin/grep

sls_build/image_build.sls:

{% for symlink in salt['pillar.get']('symlinks') %}
Create symlink {{symlink}}:
  file.symlink:
    - name: {{symlink}}
    - target: {{salt['pillar.get']('target')}}
    - makedirs: True
    - force: True
{% endfor %}
Steps to Reproduce Issue

Run: salt-call state.sls sls_build

Output:

local:
----------
          ID: Build image with SLS
    Function: docker_image.present
        Name: sls_build
      Result: False
     Comment: Encountered error using SLS sls_build.image_build for building sls_build:latest:
     Started: 05:14:52.140272
    Duration: 43433.84 ms
     Changes:

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:  43.434 s

Looking at the log, I see this as the actual failure:

[INFO    ] Executing command 'docker exec bf0e2f59d76e7cecf100140272999e0f436a95dbeeb91c8aabba07fed9e3a2a6 env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin  python2 /tmp/salt.docker.7c6553/salt-call --me
tadata --local --log-file /tmp/salt.docker.7c6553/log --cachedir /tmp/salt.docker.7c6553/cache --out json -l quiet -- state.pkg /tmp/salt.docker.6e3a74/salt_state.tgz d930f60266fffad2fa36af28d9444258375ac650ba87fb28a20148f6a3a3b34a sha2
56' in directory '/home/clallen'
[ERROR   ] Command 'docker exec bf0e2f59d76e7cecf100140272999e0f436a95dbeeb91c8aabba07fed9e3a2a6 env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin  python2 /tmp/salt.docker.7c6553/salt-call --metadata --l
ocal --log-file /tmp/salt.docker.7c6553/log --cachedir /tmp/salt.docker.7c6553/cache --out json -l quiet -- state.pkg /tmp/salt.docker.6e3a74/salt_state.tgz d930f60266fffad2fa36af28d9444258375ac650ba87fb28a20148f6a3a3b34a sha256' failed
 with return code: 1
[ERROR   ] stdout: {
    "local": {
        "fun_args": [
            "/tmp/salt.docker.6e3a74/salt_state.tgz",
            "d930f60266fffad2fa36af28d9444258375ac650ba87fb28a20148f6a3a3b34a",
            "sha256"
        ],
        "jid": "20191218111521368496",
        "return": {},
        "retcode": 2,
        "fun": "state.pkg",
        "id": "bf0e2f59d76e",
        "out": "highstate"
    }
}
[ERROR   ] retcode: 1

I can provide full debug output if needed.

Versions Report

Salt Version:
Salt: 2019.2.2

Dependency Versions:
cffi: 1.6.0
cherrypy: 17.4.2
dateutil: 2.8.1
docker-py: 4.1.0
gitdb: 2.0.6
gitpython: 2.1.14
ioflo: Not Installed
Jinja2: 2.10.3
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.6.2
mysql-python: 1.2.5
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.5 (default, Apr 9 2019, 16:02:27)
python-gnupg: 0.4.5
PyYAML: 3.13
PyZMQ: 18.1.0
RAET: Not Installed
smmap: 2.0.5
timelib: Not Installed
Tornado: 5.1.1
ZMQ: 4.3.2

System Versions:
dist: oracle 7.6
locale: UTF-8
machine: x86_64
release: 4.14.35-1844.4.5.2.el7uek.x86_64
system: Linux
version: Oracle Linux Server 7.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with salt-call state.sls sls_build using docker.image.present and the sls_build.image_build SLS example. Trace the docker.image.present path through its state.pkg call for salt_state.tgz and inspect the reported retcode 2. Done means the SLS-based image build completes without the state.pkg failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.