Repository navigation
Description
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
basepi commentedon Jan 8, 2014
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.
bbinet commentedon Jan 9, 2014
I came across the exact same issue today:
https://groups.google.com/d/msg/salt-users/zx1VHnGx2lI/r4G6spQu2QsJ
basepi commentedon Jan 9, 2014
@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.
bbinet commentedon Jan 9, 2014
@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:
So I may face the same gitfs cache issue as @Vye.
basepi commentedon Jan 11, 2014
Thanks for the clarification. We'll figure out what's going on here.
terminalmage commentedon Jan 13, 2014
This is not actually a bug. See the docs on how top files are compiled.
You have a top.sls in both the
masteranddevenvironments, and as a result thedevsection in thedevenvironment's top.sls is being ignored.You can either remove the
devsection from themasterenv's top.sls, or remove the top.sls from thedevenvironment, 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.
terminalmage commentedon Jan 13, 2014
I've updated the name of this issue to reflect the actual problem.
terminalmage commentedon Jan 19, 2014
@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.
bbinet commentedon Jan 20, 2014
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?
Vye commentedon Jan 25, 2014
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.
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?
basepi commentedon Jan 29, 2014
So you actually can isolate top files. Instead of running
state.highstate, try runningstate.top. You specify a specific topfile to run rather than combining all of the top files. (Note that forstate.topit doesn't actually even have to be namedtop.sls.)Vye commentedon Feb 3, 2014
@basepi,
I tried out state.top, and got an error like this for each of my states:
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.
basepi commentedon Feb 5, 2014
Can you show me the
state.topcommand 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 samesalt://path across environments. I haven't usedstate.topextensively, but definitely want to make it so it's usable for this type of versioning across branches/environments.Vye commentedon Feb 21, 2014
@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:
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:
Now, in this example there is a single top file that uses the environment
basewhich we know references only themasterbranch. 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:
basepi commentedon Feb 21, 2014
Could you try the same command but define the environment you're trying to target?
Curious if that will limit it to the correct environment or not.
Vye commentedon Feb 21, 2014
Seems like it doesn't. No change.
basepi commentedon Feb 21, 2014
Looks like
state.topmust not supportsaltenvproperly. Good to know, we need to get that fixed.basepi commentedon Feb 21, 2014
Opened #10660.
stale commentedon Dec 22, 2017
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.