Problem state.apply in 2016.3.3
Description of Issue/Question
Trying to apply states using a grain to specify the environment. This used to work in 2015.x.x but doesn't seem to work in 2016.3.3. The file system back end is gitfs with two branches master=>base and dev.
Setup
(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).) File server setup on master:
top_file_merging_strategy: same
default_top: base
hash_type: sha256
fileserver_backend:
- git
gitfs_provider: pygit2
gitfs_pubkey: id_rsa.pub
gitfs_privkey: id_rsa
gitfs_remotes:
- git@git-01-v:/git/salt_states.git:
- base: master
- git@git-01-v:/git/salt_reactor.git:
- mountpoint: salt://reactor
gitfs_env_whitelist:
- base
- dev
The Top file:
{% set GrainEnv = salt['grains.get']('acSaltEnv', 'base') %}
{{ GrainEnv }}:
'*':
- testing
salt '*test*' grains.get acSaltEnv output:
test-01-v:
dev
test-02-v:
Steps to Reproduce Issue
(Include debug logs if possible and relevant.) On the master run:
salt 'test*' state.apply
Output is:
test-01-v:
----------
ID: states
Function: no.None
Result: False
Comment: No Top file or external nodes data matches found.
Started:
Duration:
Changes:
Summary for test-01-v
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 0.000 ms
test-02-v:
----------
ID: Run a test
Function: cmd.run
Name: echo "Master branch - base."
Result: True
Comment: Command "echo "Master branch - base."" run
Started: 10:43:05.588619
Duration: 21.098 ms
Changes:
----------
pid:
27965
retcode:
0
stderr:
stdout:
Master branch - base.
Summary for test-02-v
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 21.098 ms
In previous versions both minions would run state files from their respective environments / branches. Now until you specify the saltenv, the minion will not run the state file.
Versions Report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Master Version Report:
Salt Version:
Salt: 2016.3.3
Dependency Versions:
cffi: 0.8.6
cherrypy: Not Installed
dateutil: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
ioflo: 1.3.8
Jinja2: 2.7.2
libgit2: 0.21.0
libnacl: 1.4.3
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pygit2: 0.21.4
Python: 2.7.5 (default, Sep 15 2016, 22:37:39)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: 0.6.3
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: centos 7.2.1511 Core
machine: x86_64
release: 3.10.0-327.36.2.el7.x86_64
system: Linux
version: CentOS Linux 7.2.1511 Core
test-01-v Version Report:
Salt Version:
Salt: 2016.3.3
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 1.4.1
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.3
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.20.2
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: centos 6.8 Final
machine: x86_64
release: 2.6.32-642.6.1.el6.x86_64
system: Linux
version: CentOS 6.8 Final
test-02-v Version Report:
Salt Version:
Salt: 2016.3.3
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.5 (default, Sep 15 2016, 22:37:39)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: centos 7.2.1511 Core
machine: x86_64
release: 3.10.0-327.36.2.el7.x86_64
system: Linux
version: CentOS Linux 7.2.1511 Core
I have confirmed I am getting the same error with the following repository.
https://github.com/gtmanfred/issue-37096
Which version of salt has this worked with in the past?
@gtmanfred I recently switched over to using the official salt repos for CentOS 6 & 7. Prior to that I used the epel repo. This worked in 2015.5.10 from epel and I believe it worked in 2015.8 as well. Thanks for looking into this.
I was able to get it to work on 2015.5.10, but 2015.8.12 is also broken.
I can't reproduce this at all.
acSaltEnv is not a core grain, so how is this being set for your minions?
I set it in /etc/salt/grains and then did a refresh_modules.
So did I. Still can't reproduce.
I published a docker image that has it replicated
daniel jenny roster
~github salt ➤ docker run --rm -ti gtmanfred/issues:37096 salt-call grains.get acSaltEnv
[WARNING ] /usr/lib/python2.7/site-packages/salt/grains/core.py:1493: DeprecationWarning: The "osmajorrelease" will be a type of an integer.
local:
dev
daniel jenny roster
~github salt ➤ docker run --rm -ti gtmanfred/issues:37096 salt-call state.apply
[WARNING ] /usr/lib/python2.7/site-packages/salt/grains/core.py:1493: DeprecationWarning: The "osmajorrelease" will be a type of an integer.
local:
----------
ID: states
Function: no.None
Result: False
Comment: No Top file or external nodes data matches found.
Started:
Duration:
Changes:
Summary for local
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 0.000 ms
OK, I found why I couldn't reproduce. I had more than one minion.d conf file with top_flie_merging_strategy set, and it was being overridden to merge instead of same.
So, this issue has been caused, from what I can see, by the fact that the top file merging strategies did not work as documented. I did a lot of work to correct top file merging recently, but this work was done in the Carbon release branch (i.e. 2016.11). The reason for this was that @thatch45 and I decided that changing something important like top file merging in a point release is not a good idea.
I ran @gtmanfred's docker container in interactive mode and upgraded salt to the head of the 2016.11 release branch, and confirmed that this is fixed. See here for the terminal log.
Given the fact that this is fixed in the next feature release, and the fact that @thatch45 and I are both against modifying top file merging in a point release, I think we should consider this issue resolved, though I would like to get some input from the rest of the core dev team.