-
Notifications
You must be signed in to change notification settings - Fork 2.2k
(PUP-2520) implements 'manual' environment directories #2638
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
(PUP-2520) implements 'manual' environment directories #2638
Conversation
lib/puppet/environments.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think it is a good idea to use the file_watcher (quite a bit of overhead), and it is unclear why it is needed here - I see no instantiation of Puppet::Util::FileWatcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a left-over from a previous implementation that was using the file watcher. The thing wasn't really working correctly so I backtracked to a regular check but forgot the require.
I'll remove it soon.
CLA signed by all contributors. |
A general comment: the "manual" is not 100% manual since I think the ctime changes if there are changes to the content of the directory. This means that the cache is flushed for the env at other times than the manual touching of the directory itself. This in turn means that a user that expects to be able to do several operations before manually flushing may be surprised and that the resulting catalog may be based on partial, incomplete input. |
@hlindberg at least on my mac and linux boxes, both ctime and mtime change if I add a file to the root of the environment directory. Any other changes don't change ctime nor mtime. A change below the first directory level don't change ctime nor mtime. |
@hlindberg do you prefer the fixes as a new commit or I rebase and push everything? |
The distinction between ctime and mtime is kind of fuzzy, and I don't know the exact semantics for a directory, but I think ctime is fine (you get file +/- in the watched dir, plus changes to the directory's permissions etc). To make an atomic operation a user needs to switch the directories, a copy is not atomic where there is more than one file to copy, it would change the ctime multiple times, and worst case is that the environment does not contain everything that it is supposed to contain. (i.e. using symlinks, the changing of the symlink is atomic). You can push new commits if you like. |
Hi, I've rebased the commits with the following changes:
Let me know if you have more comments! |
lib/puppet/environments.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Macro typo: loader_get_environment_dir :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
I will amend the patch ASAP
I just repushed the PR to take into account @jpartlow comment. |
lib/puppet/face/environment.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
environment misspelled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ferventcoder good catch!
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
This allows to test ctime changes on a given file. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
This touches only the ctime of a given MemoryFile, which is useful to test watched files. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
This is implemented only for directory based environments and returns the path to the environment directory of the given environment. Other loaders doesn't return any valid information (ie nil). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Those are created with an environment_timeout value of "manual". Those environments are cached indefinitely unless their directories are manually touched (ie its ctime must change). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
This face allows to: * list defined environments (including details with --details) * flush one,several or all environements (this touches the environment directory). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
I rebased the commits on the current master, and fixed the misspelling @ferventcoder found. |
We were discussing this in the pr triage today, and we are concerned about the time it will take to get this tested on our various platforms (specifically passing on Windows :). With all the work still outstanding for 3.7, we would like to leave this be until we are able to begin work on Puppet 4. There was also discussion that the docs should be adjusted to warn that manually refreshing environments has the added problem that it won't reload ruby code (compared to a graceful restart of the server). |
@jpartlow ok, thanks for the information. I can't promise I'll be able to maintain this PR until you'll be ready to look at it :) Regarding Windows, the current code is using the exact same semantics as the Puppet file watcher. If this last one works on Windows, then there's very great chances this code will work as-is :) Regarding reloading ruby code, the issue is then the same when |
@masterzen yeah, the ruby reloading is the same with any of the evictions that try to reload the environment within a process. That is why I pushed so much so keep it to the timeouts and unlimited, with the preference for users to use unlimited. I was concerned that the "manual" mode would look too much like unlimited with a graceful restart, but not be able to achieve any of its guarantees. |
@zaphod42 sorry, but I fail to see how this is a different behavior than with the legacy dynamic environments? People lived with that for many years and to my knowledge didn't complain that loudly (at least not to me). Directory environments weren't really created to solve the ruby reloading issue (or I missed the memo :), but to have a sane and direct configuration mechanism based on a proven convention (that mimics a lot what people were doing). Anyway, if this PR proves to not be such a good idea, let's get rid of it before I spend too much time fixing the comments so that it get accepted :) |
Hi Brice, We discussed this more at the triage today, and in the end we don't want to take on the overhead of maintenance for this when we are agreed that the preferred method for a restart should be an unlimited timeout and a graceful restart of the server. All of the restart options have potential issues, but the manual timeout has the most problems. Apologies for getting you started on this; we should have come to a clear decision before opening the original ticket. |
Hi,
Please find here an implementation of the 'manual' type of directory environments, along with a puppet face to list the environements and flush them.
I tried to cover the whole feature with as much tests I can, but I didn't provide any acceptance tests.
It's been a long time since I contributed some code to Puppet, so please bear with me and do not hesitate to comment the following patches!
Thanks!
Brice