Skip to content

Provide CLI notification for conflicting environment entries when compiling highstate #9616

Closed

Description

@Vye

The other day I noticed that some of my formulas were not being applied in highstate. From what I can tell the problem occurs when I use gitfs as the backend. I checked the cache directory and found a couple formula directories missing.

I've searched all over for an open bug report but couldn't find one. Yet I can't help but wonder why no one else seems to be having this issue.

I created a test repo (https://github.com/Vye/gitfstest/tree/dev) so this can be easily reproduced. There were no errors or odd warnings in the log files during the highstate.

I first noticed the issue with 0.17.4 but have reproduced it in the develop branch as well.

$ cat /etc/redhat-release 
CentOS release 6.3 (Final)
$ salt --versions-report
           Salt: 0.17.4
         Python: 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
         Jinja2: unknown
       M2Crypto: 0.20.2
 msgpack-python: 0.1.13
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
         PyYAML: 3.10
          PyZMQ: 2.2.0.1
            ZMQ: 3.2.4
$ rpm -q GitPython
GitPython-0.3.2-0.1.RC1.el6.noarch

based on 'develop' branch:

$ cat /etc/redhat-release 
CentOS release 6.5 (Final)
$ salt --versions-report
Salt: 2014.1.0-147-g3152e26
         Python: 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
         Jinja2: 2.7.1
       M2Crypto: 0.21.1
 msgpack-python: 0.4.0
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
         PyYAML: 3.10
          PyZMQ: 14.0.1
            ZMQ: 4.0.3
$ pip freeze | grep Git
GitPython==0.3.2.RC1

I added each formula one at a time and gitfs updated just fine until the fourth one, then it stopped populating the rest (there are five at this point). I have deleted the gitfs cache and restarted the salt-master half a dozen times with the same results.

ls var/cache/salt/master/gitfs/refs/dev
formula1  formula2  formula3  top.sls

The above should have formula4 and formula5 folders as well.

highstate output:

$ salt -c ./etc/salt '*' state.highstate test=True
saltdev:
----------
          ID: /formula2
    Function: file.managed
      Result: None
     Comment: The following values are set to be changed:
              newfile: /formula2
     Changes:   
              ----------
----------
          ID: /formula3
    Function: file.managed
      Result: None
     Comment: The following values are set to be changed:
              newfile: /formula3
     Changes:   
              ----------
----------
          ID: /formula1
    Function: file.managed
      Result: None
     Comment: The following values are set to be changed:
              newfile: /formula1
     Changes:   
              ----------

Summary
------------
Succeeded: 0
Failed:    0
Not Run:   3
------------
Total:     3

I've gisted my 'develop' master and minion config here: https://gist.github.com/Vye/359c1db233901d80da4f

Can someone else try and see if they are able to reproduce this issue?

Activity

  1. basepi commented on Jan 8, 2014

    @basepi
    Contributor

    Hrm, interesting. I assume the problem occurs no matter which repos you use as formula4 or formula5? And that formula4 and formula5 work fine if you don't have the others? Just want to rule out a repo-specific issue.

  2. basepi commented on Jan 9, 2014

    @basepi
    Contributor

    @bbinet I may be missing something in my cursory skim of that thread, but it seems like your issue may not be quite the same -- you are only using a single remote, and it seems to be some sort of a bug related to gitfs_root.

  3. bbinet commented on Jan 9, 2014

    @bbinet
    Contributor

    @basepi: as I told on the mailing list, when using this repository as a gitfs backend, the generated cache looks wrong to me, because for example there is nothing in refs/dev whereas the dev branch is not empty.
    Here is the complete generated gitfs cache for the https://github.com/bbinet/gitfs-test state tree:

    $ tree /var/cache/salt/master/gitfs/
    /var/cache/salt/master/gitfs/
    ├── 274870257c54ca419467427acad35360
    ├── hash
    │   └── master
    │       └── states
    └── refs
        ├── dev
        │   └── states
        └── master
            └── states
                ├── states
                └── top.sls
    

    So I may face the same gitfs cache issue as @Vye.

  4. basepi commented on Jan 11, 2014

    @basepi
    Contributor

    Thanks for the clarification. We'll figure out what's going on here.

  5. terminalmage commented on Jan 13, 2014

    @terminalmage
    Contributor

    This is not actually a bug. See the docs on how top files are compiled.

    You have a top.sls in both the master and dev environments, and as a result the dev section in the dev environment's top.sls is being ignored.

    You can either remove the dev section from the master env's top.sls, or remove the top.sls from the dev environment, and this should work as expected.

    Despite this being well-explained in the docs, I think we should probably provide notification of this on the CLI when running a highstate, since this still catches quite a few people.

  6. terminalmage commented on Jan 13, 2014

    @terminalmage
    Contributor

    I've updated the name of this issue to reflect the actual problem.

  7. terminalmage commented on Jan 19, 2014

    @terminalmage
    Contributor

    @Vye I just wanted to follow up with you to see if you were able to resolve your issue using the information I mentioned above.

  8. bbinet commented on Jan 20, 2014

    @bbinet
    Contributor

    I thought my issue was the same as @Vye, but if this issue is not actually a bug, I may encounter a different problem because my top.sls file is located only in the base branch, nothing in the dev branch. (see https://groups.google.com/d/msg/salt-users/zx1VHnGx2lI/r4G6spQu2QsJ for more information).
    Should I create a separate issue for my own gitfs problem?

  9. Vye commented on Jan 25, 2014

    @Vye
    ContributorAuthor

    I looked over this again and it seems I did goof up as it behaves the way @terminalmage and the docs state. My apologies, hopefully too much time wasn't spent investigating this.

    My original intent was to get around having to version my top file separately from my environment branches. I want the top file changes to go through the same branches that the rest of the formulas have to go through. I'm still trying to figure out a way to do this.

    I have a dedicated master for each of my environment branches. Only minions that match the environment of the master get their keys authorized on that master (dev minion -> dev master; qa minion -> qa master). To promote top files and formulas I want to merge a commit through the branches: dev -> qa -> prod.

    The approach the docs suggest is great if you have a single master serving multiple environments, but I want more isolation between masters. This makes automated testing easier but also the master is important, seems only prudent to properly exercise the top file with the rest of the formulas.

    I can't isolate top files to a single environment (even though they will all be merged together) because when they get promoted to the next environment the environment key will still be from the last branch.

    e.g. the following top file would only work in dev, once it was promoted to qa it would be incorrect.

    dev:
      '*':
        - formula
    

    Maybe I'm going about this the wrong way. Any thoughts on how I might be able to version the top file WITH my formulas?

  10. basepi commented on Jan 29, 2014

    @basepi
    Contributor

    So you actually can isolate top files. Instead of running state.highstate, try running state.top. You specify a specific topfile to run rather than combining all of the top files. (Note that for state.top it doesn't actually even have to be named top.sls.)

  11. Vye commented on Feb 3, 2014

    @Vye
    ContributorAuthor

    @basepi,

    I tried out state.top, and got an error like this for each of my states:

        Detected conflicting IDs, SLS IDs need to be globally unique.
        The conflicting ID is "collectd" and is found in SLS "prod:collectd" and SLS "dev:collectd"
    

    It seems for this approach to work I would need to be able to specify an explicit branch like you can do with pillar data.

    I'm quite perplexed. GitFS doesn't seem to allow you to use branches to promote your formulas through environments. If you do, they won't be unique. I can't see how GitFS is a viable option without that functionality. Why not use a file_root if that is the case?

    Does what I'm trying to do make sense? Should I run the question by the mailing list to see what others are doing?

    Thanks for your help.

  12. basepi commented on Feb 5, 2014

    @basepi
    Contributor

    Can you show me the state.top command you used? Additionally, is there an instance of that topfile in each environment/branch or only in one? It may be that it's combining topfiles of the same salt:// path across environments. I haven't used state.top extensively, but definitely want to make it so it's usable for this type of versioning across branches/environments.

  13. Vye commented on Feb 21, 2014

    @Vye
    ContributorAuthor

    @basepi,

    I've looked at this more and put together some more examples for you to see what I'm trying to do. Keep in mind that either of these approaches could work, but since I cannot explicitly control which git branch gitfs should read from (like ext_pillar), they don't.

    Example: multiple top files
    Master config:

    fileserver_backend:
      - git
    gitfs_remotes:
      - git://github.com/Vye/testing_salt_issue_9616_topfiles.git
    $ salt-call -c ~/repos/salt_venv/etc/salt state.top devtop.sls test=True     
    [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be accurate.
    /home/vye/repos/salt_venv/lib/python2.6/site-packages/salt/minion.py:166: DeprecationWarning: This minion recieved a job where kwargs were passed as string'd args, which has been deprecated. This functionality will be removed in Salt Boron.
      'This minion recieved a job where kwargs were passed as '
    [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'prod', ** done ** 'devtop.sls'
    [INFO    ] Fetching file from saltenv 'dev', ** done ** 'devtop.sls'
    [INFO    ] Fetching file from saltenv 'stage', ** done ** 'devtop.sls'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/modules'
    [INFO    ] Syncing modules for environment 'dev'
    [INFO    ] Loading cache from salt://_modules, for dev)
    [INFO    ] Caching directory '_modules/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/states'
    [INFO    ] Syncing states for environment 'dev'
    [INFO    ] Loading cache from salt://_states, for dev)
    [INFO    ] Caching directory '_states/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/grains'
    [INFO    ] Syncing grains for environment 'dev'
    [INFO    ] Loading cache from salt://_grains, for dev)
    [INFO    ] Caching directory '_grains/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/renderers'
    [INFO    ] Syncing renderers for environment 'dev'
    [INFO    ] Loading cache from salt://_renderers, for dev)
    [INFO    ] Caching directory '_renderers/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/returners'
    [INFO    ] Syncing returners for environment 'dev'
    [INFO    ] Loading cache from salt://_returners, for dev)
    [INFO    ] Caching directory '_returners/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/outputters'
    [INFO    ] Syncing outputters for environment 'dev'
    [INFO    ] Loading cache from salt://_outputters, for dev)
    [INFO    ] Caching directory '_outputters/' for environment 'dev'
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'dev', ** done ** 'formula1.sls'
    [INFO    ] Running state [/goodfile_with_bug] at time 18:05:33.797229
    [INFO    ] Executing state file.managed for /goodfile_with_bug
    [INFO    ] {'newfile': '/goodfile_with_bug'}
    [INFO    ] The following values are set to be changed:
    newfile: /goodfile_with_bug
    
    [INFO    ] Completed state [/goodfile_with_bug] at time 18:05:34.280031
    local:
    ----------
              ID: /goodfile_with_bug
        Function: file.managed
          Result: None
         Comment: The following values are set to be changed:
                  newfile: /goodfile_with_bug
         Changes:   
    
    Summary
    ------------
    Succeeded: 0
    Failed:    0
    Not Run:   1
    ------------
    Total:     1

    The command above should have produced an error because the dev version of the topfile is actually broken, referencing a sls that doesn't exist: https://github.com/Vye/testing_salt_issue_9616_topfiles/commit/e44284b761b0beb705bed32099f0b2aa78f0f565

    It looks like the top files are merged, but I wonder how because I still expected an error... Regardless, it does not provide the isolation I'm looking for. Additionally, I have to maintain 3 top files in 3 branches... I should be able to have a single top file that moves through dev, stage, and prod as it is tested and proven.

    Example: single top file
    Master config:

    fileserver_backend:
      - git
    gitfs_remotes:
      - git://github.com/Vye/testing_salt_issue_9616.git
    $ salt-call -c ~/repos/salt_venv/etc/salt state.highstate test=True
    [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be accurate.
    /home/vye/repos/salt_venv/lib/python2.6/site-packages/salt/minion.py:166: DeprecationWarning: This minion recieved a job where kwargs were passed as string'd args, which has been deprecated. This functionality will be removed in Salt Boron.
      'This minion recieved a job where kwargs were passed as '
    [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'stagetopfiles', ** done ** 'top.sls'
    [INFO    ] Fetching file from saltenv 'devtopfiles', ** done ** 'top.sls'
    [INFO    ] Fetching file from saltenv 'prodtopfiles', ** done ** 'top.sls'
    [INFO    ] Fetching file from saltenv 'dev', ** done ** 'top.sls'
    [INFO    ] Fetching file from saltenv 'topfiles', ** done ** 'top.sls'
    [INFO    ] Fetching file from saltenv 'prod', ** done ** 'top.sls'
    [INFO    ] Fetching file from saltenv 'stage', ** done ** 'top.sls'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/modules'
    [INFO    ] Syncing modules for environment 'base'
    [INFO    ] Loading cache from salt://_modules, for base)
    [INFO    ] Caching directory '_modules/' for environment 'base'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/states'
    [INFO    ] Syncing states for environment 'base'
    [INFO    ] Loading cache from salt://_states, for base)
    [INFO    ] Caching directory '_states/' for environment 'base'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/grains'
    [INFO    ] Syncing grains for environment 'base'
    [INFO    ] Loading cache from salt://_grains, for base)
    [INFO    ] Caching directory '_grains/' for environment 'base'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/renderers'
    [INFO    ] Syncing renderers for environment 'base'
    [INFO    ] Loading cache from salt://_renderers, for base)
    [INFO    ] Caching directory '_renderers/' for environment 'base'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/returners'
    [INFO    ] Syncing returners for environment 'base'
    [INFO    ] Loading cache from salt://_returners, for base)
    [INFO    ] Caching directory '_returners/' for environment 'base'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/outputters'
    [INFO    ] Syncing outputters for environment 'base'
    [INFO    ] Loading cache from salt://_outputters, for base)
    [INFO    ] Caching directory '_outputters/' for environment 'base'
    [INFO    ] Loading fresh modules for state activity
    local:
        Data failed to compile:
    ----------
        No matching sls found for 'formula1' in env 'base'

    Now, in this example there is a single top file that uses the environment base which we know references only the master branch. That's the source of the error. However, if I could explicitly tell gitfs to use dev, stage, or prod in the salt master's config (like ext_pillar) then this would work perfectly because I don't have to manage three separate top files AND I get isolation between environments.

    I think that the flexibility of the topfile and gitfs now is good but It would be even better if it allowed you to explicitly limit which branches it pulled data from.

    like this:

    gitfs_remotes:
      - <branch> git://github.com/Vye/testing_salt_issue_9616.git
  14. basepi commented on Feb 21, 2014

    @basepi
    Contributor

    Could you try the same command but define the environment you're trying to target?

    salt-call -c ~/repos/salt_venv/etc/salt state.top devtop.sls test=True saltenv=<my_env_here>
    

    Curious if that will limit it to the correct environment or not.

  15. Vye commented on Feb 21, 2014

    @Vye
    ContributorAuthor

    Seems like it doesn't. No change.

    $ salt-call -c ~/repos/salt_venv/etc/salt state.top devtop.sls test=True saltenv=dev
    [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be accurate.
    /home/vye/repos/salt_venv/lib/python2.6/site-packages/salt/minion.py:166: DeprecationWarning: This minion recieved a job where kwargs were passed as string'd args, which has been deprecated. This functionality will be removed in Salt Boron.
      'This minion recieved a job where kwargs were passed as '
    [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be accurate.
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'prod', ** skipped ** latest already in cache 'salt://devtop.sls'
    [INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache 'salt://devtop.sls'
    [INFO    ] Fetching file from saltenv 'stage', ** skipped ** latest already in cache 'salt://devtop.sls'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/modules'
    [INFO    ] Syncing modules for environment 'dev'
    [INFO    ] Loading cache from salt://_modules, for dev)
    [INFO    ] Caching directory '_modules/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/states'
    [INFO    ] Syncing states for environment 'dev'
    [INFO    ] Loading cache from salt://_states, for dev)
    [INFO    ] Caching directory '_states/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/grains'
    [INFO    ] Syncing grains for environment 'dev'
    [INFO    ] Loading cache from salt://_grains, for dev)
    [INFO    ] Caching directory '_grains/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/renderers'
    [INFO    ] Syncing renderers for environment 'dev'
    [INFO    ] Loading cache from salt://_renderers, for dev)
    [INFO    ] Caching directory '_renderers/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/returners'
    [INFO    ] Syncing returners for environment 'dev'
    [INFO    ] Loading cache from salt://_returners, for dev)
    [INFO    ] Caching directory '_returners/' for environment 'dev'
    [INFO    ] Creating module dir '/home/vye/repos/salt_venv/var/cache/salt/minion/extmods/outputters'
    [INFO    ] Syncing outputters for environment 'dev'
    [INFO    ] Loading cache from salt://_outputters, for dev)
    [INFO    ] Caching directory '_outputters/' for environment 'dev'
    [INFO    ] Loading fresh modules for state activity
    [INFO    ] Fetching file from saltenv 'dev', ** skipped ** latest already in cache 'salt://formula1.sls'
    [INFO    ] Running state [/goodfile_with_bug] at time 13:15:42.143354
    [INFO    ] Executing state file.managed for /goodfile_with_bug
    [INFO    ] {'newfile': '/goodfile_with_bug'}
    [INFO    ] The following values are set to be changed:
    newfile: /goodfile_with_bug
    
    [INFO    ] Completed state [/goodfile_with_bug] at time 13:15:42.557182
    local:
    ----------
              ID: /goodfile_with_bug
        Function: file.managed
          Result: None
         Comment: The following values are set to be changed:
                  newfile: /goodfile_with_bug
         Changes:   
    
    Summary
    ------------
    Succeeded: 0
    Failed:    0
    Not Run:   1
    ------------
    Total:     1
  16. basepi commented on Feb 21, 2014

    @basepi
    Contributor

    Looks like state.top must not support saltenv properly. Good to know, we need to get that fixed.

  17. basepi commented on Feb 21, 2014

    @basepi
    Contributor

    Opened #10660.

  18. added
    severity-medium
    Core
    P3
    and removed on Aug 25, 2015
  19. stale commented on Dec 22, 2017

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

    If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CoreP3bugdocumentationseverity-mediumstale

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions