{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/43293","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/43293/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/43293/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/43293/events","html_url":"https://github.com/saltstack/salt/issues/43293","id":254454138,"number":43293,"title":"Issue with top_file_merging_strategy same","user":{"login":"ccoughle","id":17281294,"avatar_url":"https://avatars2.githubusercontent.com/u/17281294?v=4","gravatar_id":"","url":"https://api.github.com/users/ccoughle","html_url":"https://github.com/ccoughle","followers_url":"https://api.github.com/users/ccoughle/followers","following_url":"https://api.github.com/users/ccoughle/following{/other_user}","gists_url":"https://api.github.com/users/ccoughle/gists{/gist_id}","starred_url":"https://api.github.com/users/ccoughle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccoughle/subscriptions","organizations_url":"https://api.github.com/users/ccoughle/orgs","repos_url":"https://api.github.com/users/ccoughle/repos","events_url":"https://api.github.com/users/ccoughle/events{/privacy}","received_events_url":"https://api.github.com/users/ccoughle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-08-31T20:13:14Z","updated_at":"2017-09-01T15:36:43Z","closed_at":null,"author_association":"NONE","body":"### Description of Issue/Question\r\n\r\nWe have about 10 different environments set for the machines we manage.  File roots look like this:\r\n\r\n```\r\nfile_roots:\r\n  base:\r\n    - /srv/salt/base\r\n  dev:\r\n    - /srv/salt/dev\r\n    - /srv/salt/base\r\n    - /srv/salt/common\r\n  env1:\r\n    - /srv/salt/env1\r\n    - /srv/salt/base\r\n    - /srv/salt/common\r\n```\r\n\r\nour merge strategy is set to same.  Environments are configured on the minions in minion.d\r\nThis works well for us, allow shared states between environments along with isolation of environments.  However, we had an issue where the environments specified on the minions got blanked out.  So, in absence of a defined environment; all the top files in all environments were merged.  \r\n\r\nThe \"base\" environment's top file contains only a single state that manages the salt minion's configs and applies configs, such as the minion's defined environment, based on an external pillar source (cobbler in this case).\r\n\r\nOur expectation was that if a environment was ever not specified, the minion would run just the top file for the base environment.  (default_top is set to base)  \r\nSo, we tested two configurations of env_order to see if we could enforce this behavior.  \r\n\r\nenv_order: ['base']\r\nand\r\nenv_order: ['base', 'dev', 'env1', 'env2', 'env3', 'env4', 'env5', 'env6', 'env7, 'env8']\r\n\r\nenv_order: ['base'] resulted in the base top file being run when no environment was specified.  But, after an environment was specified on the minion, a state.apply would fail with as the minion could only see the base environment.  (state.show_top would generate the correct top file however)\r\n\r\nenv_order: ['base', 'dev', 'env1', 'env2', 'env3', 'env4', 'env5', 'env6', 'env7, 'env8'] \r\nThis time, the correct top file was run when the environment was specified on the minion.  But, if no environment is specified, all the top files are merged.  \r\n\r\nSo, there seems to be no way to get the functionality of running only the base top file when no environment is specified and following the merge strategy same when an environment is specified.  \r\n\r\n\r\nThe above tests seem to be in conflict with the describe behavior of default_top\r\n\r\n\"When top_file_merging_strategy is set to same, and no environment is specified for a highstate (i.e. environment is not set for the minion), this config option specifies a fallback environment in which to look for a top file if an environment lacks one.\"\r\n\r\n\r\n### Setup\r\n(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)\r\n\r\n### Steps to Reproduce Issue\r\n(Include debug logs if possible and relevant.)\r\n\r\n### Versions Report\r\n(Provided by running `salt --versions-report`. Please also mention any differences in master/minion versions.)\r\nalt Version:\r\n           Salt: 2017.7.1\r\n\r\nDependency Versions:\r\n           cffi: Not Installed\r\n       cherrypy: unknown\r\n       dateutil: Not Installed\r\n      docker-py: Not Installed\r\n          gitdb: Not Installed\r\n      gitpython: Not Installed\r\n          ioflo: Not Installed\r\n         Jinja2: 2.7.2\r\n        libgit2: Not Installed\r\n        libnacl: Not Installed\r\n       M2Crypto: Not Installed\r\n           Mako: Not Installed\r\n   msgpack-pure: Not Installed\r\n msgpack-python: 0.4.7\r\n   mysql-python: Not Installed\r\n      pycparser: Not Installed\r\n       pycrypto: 2.6.1\r\n   pycryptodome: 3.4.3\r\n         pygit2: Not Installed\r\n         Python: 2.7.5 (default, Nov  6 2016, 00:28:07)\r\n   python-gnupg: Not Installed\r\n         PyYAML: 3.11\r\n          PyZMQ: 15.3.0\r\n           RAET: Not Installed\r\n          smmap: Not Installed\r\n        timelib: Not Installed\r\n        Tornado: 4.2.1\r\n            ZMQ: 4.1.4\r\n\r\nSystem Versions:\r\n           dist: centos 7.3.1611 Core\r\n         locale: UTF-8\r\n        machine: x86_64\r\n        release: 3.10.0-514.26.2.el7.x86_64\r\n         system: Linux\r\n        version: CentOS Linux 7.3.1611 Core\r\n"},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/326612827","html_url":"https://github.com/saltstack/salt/issues/43293#issuecomment-326612827","issue_url":"https://api.github.com/repos/saltstack/salt/issues/43293","id":326612827,"user":{"login":"Ch3LL","id":6886822,"avatar_url":"https://avatars3.githubusercontent.com/u/6886822?v=4","gravatar_id":"","url":"https://api.github.com/users/Ch3LL","html_url":"https://github.com/Ch3LL","followers_url":"https://api.github.com/users/Ch3LL/followers","following_url":"https://api.github.com/users/Ch3LL/following{/other_user}","gists_url":"https://api.github.com/users/Ch3LL/gists{/gist_id}","starred_url":"https://api.github.com/users/Ch3LL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ch3LL/subscriptions","organizations_url":"https://api.github.com/users/Ch3LL/orgs","repos_url":"https://api.github.com/users/Ch3LL/repos","events_url":"https://api.github.com/users/Ch3LL/events{/privacy}","received_events_url":"https://api.github.com/users/Ch3LL/received_events","type":"User","site_admin":false},"created_at":"2017-09-01T15:36:43Z","updated_at":"2017-09-01T15:36:43Z","author_association":"CONTRIBUTOR","body":"looks like i'm able to replicate this behavior and git bisect shows this commit 82bf7fe5e1e462258963db48ed88b73f0418339e which is this pr https://github.com/saltstack/salt/pull/35822\r\n\r\nHere is a docker container for someone to quickly replicate this:\r\n\r\n1. `docker run -it -v ~/git/salt/:/testing/ ch3ll/issues:43293` ( where ~/git/salt/ is a local cloned git repo of salt)\r\n2. `salt-master -d; salt-minion -d`\r\n3. `salt '*' state.highstate`\r\n\r\nAnd you will see the following:\r\n\r\n```\r\n1eb51ceec0f3:                            \r\n----------                               \r\n          ID: echo env2                  \r\n    Function: cmd.run                    \r\n      Result: True                       \r\n     Comment: Command \"echo env2\" run    \r\n     Started: 15:32:51.445430            \r\n    Duration: 135.596 ms                 \r\n     Changes:                            \r\n              ----------                 \r\n              pid:                       \r\n                  376                    \r\n              retcode:                   \r\n                  0                      \r\n              stderr:                    \r\n              stdout:                    \r\n                  env2                   \r\n----------                               \r\n          ID: echo env1                  \r\n    Function: cmd.run                    \r\n      Result: True                       \r\n     Comment: Command \"echo env1\" run    \r\n     Started: 15:32:51.581180            \r\n    Duration: 138.542 ms                 \r\n     Changes:                            \r\n              ----------                 \r\n              pid:                       \r\n                  378                    \r\n              retcode:                   \r\n                  0                      \r\n              stderr:                    \r\n              stdout:                    \r\n                  env1                   \r\n----------                               \r\n          ID: echo base                  \r\n    Function: cmd.run                    \r\n      Result: True                       \r\n     Comment: Command \"echo base\" run    \r\n     Started: 15:32:51.719870            \r\n    Duration: 131.917 ms                 \r\n     Changes:                            \r\n              ----------                 \r\n              pid:                       \r\n                  380                    \r\n              retcode:                   \r\n                  0                      \r\n              stderr:                    \r\n              stdout:                    \r\n                  base                   \r\n\r\nSummary for 1eb51ceec0f3                 \r\n------------                             \r\nSucceeded: 3 (changed=3)                 \r\nFailed:    0                             \r\n------------                             \r\nTotal states run:     3                  \r\nTotal run time: 406.055 ms               \r\n```\r\n\r\nwhich is merging all the top files from environments env1, env2, and base\r\n\r\nBut if i run this same highstate in version 2016.3.3 it only pulls in base top file:\r\n\r\n```\r\n[root@31d4427db0d1 /]# salt '*' state.highstate\r\n1eb51ceec0f3:\r\n----------\r\n          ID: echo base\r\n    Function: cmd.run\r\n      Result: True\r\n     Comment: Command \"echo base\" run\r\n     Started: 15:34:30.307752\r\n    Duration: 143.18 ms\r\n     Changes:   \r\n              ----------\r\n              pid:\r\n                  350\r\n              retcode:\r\n                  0\r\n              stderr:\r\n              stdout:\r\n                  base\r\n\r\nSummary for 1eb51ceec0f3\r\n------------\r\nSucceeded: 1 (changed=1)\r\nFailed:    0\r\n------------\r\nTotal states run:     1\r\nTotal run time: 143.180 ms\r\n```\r\n\r\nHEre are the master config settings:\r\n\r\n```\r\nfile_roots:\r\n  base:\r\n    - /srv/salt/base\r\n  env1:\r\n    - /srv/salt/env1\r\n    - /srv/salt/base\r\n  env2:\r\n    - /srv/salt/env2\r\n    - /srv/salt/base\r\ntop_file_merging_strategy: same\r\ndefault_top: base\r\n```\r\n\r\nNote: this also fails in 2016.11 but works in 2016.3.3 (the version i tested that is good)\r\n\r\nWe will need to get this fixed thanks.\r\n\r\nping @terminalmage \r\n"}}
{"actor":{"display_login":"Ch3LL"}}