Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix git_pillar race condition #31836

Merged
merged 7 commits into from Mar 14, 2016
Merged

Conversation

terminalmage
Copy link
Contributor

This pull request rewrites how salt.utils.gitfs handles locking. It also makes
two changes to how git_pillar/winrepo handle checking out a branch:

  1. If the SHA has not changed, no checkout is performed. This will vastly reduce the number of checkouts attempted and make the race condition less likely.
  2. Locking has been added to prevent concurrent _pillar master funcs from attempting to checkout at the same time. If a lock is in place, the master will wait a short period of time and try again, until the lock is removed. After the lock is gone, there should be no need to checkout the repo again since the prior instance which obtained the lock will have updated the repo. And, thanks to item 1 above, since the SHAs will now match, no checkout will be performed once the lock that was previously in place has cleared.

Fixes #31293.
EDIT: should also fix #29239.

This does a few things:

1. Introduces the concept of a checkout lock, to prevent concurrent
   "_pillar" master funcs from trying to checkout the repo at the same
   time.
2. Refrains from checking out unless the SHA has changed.
3. Cleans up some usage of the GitProvider subclass' "url" attribute
   when "id" should be used.
This is necessary for "salt-run fileserver.clear_lock" to work
@deuscapturus
Copy link
Contributor

I patched this into salt 2015.8.7. I'll let you know how it works out.

@terminalmage
Copy link
Contributor Author

@deuscapturus Thanks!

@redmcg
Copy link

redmcg commented Mar 15, 2016

@terminalmage Thanks Erik. I just applied the patch to my master (which is also now running 2015.8.7). So far so good. I did a number of salt '*' state.highstate commands (which hits 7 minions) and haven't had the git_pillar fail once.

@deuscapturus
Copy link
Contributor

@terminalmage git HEAD is not being lost. However, git_pillar updates are not working for me. When I run salt-run -l debug git_pillar.update nothing is updated. If I clear the cache and restart salt-master service I get all of the new files.

@terminalmage
Copy link
Contributor Author

@deuscapturus Thanks for the feedback, I don't think this pull request touched that file so there could be something that I need to update there to make it work with the recent updates. I'll take a look.

@terminalmage
Copy link
Contributor Author

@deuscapturus Also, keep in mind that the scheduled updates that happen every ~60 sec should still be working, at least they were for me.

@deuscapturus
Copy link
Contributor

@terminalmage We didn't see any updates for a 24 hour period after applying the patch. Again clearing cache and restarting bring the pillar cache up-to-date. We see no errors in the log. It could be that we didn't patch the master correctly. Could a new rpm build of 2015.8 be created with this fix?

@terminalmage
Copy link
Contributor Author

@deuscapturus OK thanks, I'm continuing to look into this and should have a fix today.

@terminalmage
Copy link
Contributor Author

OK, the updates are being fetched, but it appears my code for checking out the fetched updates appears not to be working. Should be easy enough to narrow down.

@terminalmage
Copy link
Contributor Author

@deuscapturus See #31903, it's a one-line change that you can apply in-place if you like to test whether or not it works for you.

@deuscapturus
Copy link
Contributor

git pillar updates are working again with #31903

I will now wait and see that the original issue is also resolved. Thank you @terminalmage for you support on this issue!

@terminalmage
Copy link
Contributor Author

Thanks for the confirmation @deuscapturus!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants