Skip to content

Conversation

masterzen
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@puppetcla
Copy link

CLA signed by all contributors.

@hlindberg
Copy link
Contributor

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.

@masterzen
Copy link
Contributor Author

@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.
I used ctime because that's what the Puppet File Watcher was using, so I thought it had a good reason to use that:
If you really want to have an atomic deployment based on watching the directory, then you need to update in a temp directory and move the directory in place. This operation only changes the ctime.

@masterzen
Copy link
Contributor Author

@hlindberg do you prefer the fixes as a new commit or I rebase and push everything?

@hlindberg
Copy link
Contributor

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.

@masterzen
Copy link
Contributor Author

Hi, I've rebased the commits with the following changes:

  • @hlindberg English comments in the Puppet face help
  • rate limit the stat(2) calls to no more than 1 per seconds
  • limit the face list command to list only directory environment

Let me know if you have more comments!
Thanks!
Brice

Copy link
Contributor

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 :)

Copy link
Contributor Author

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

@masterzen
Copy link
Contributor Author

I just repushed the PR to take into account @jpartlow comment.

@Iristyle Iristyle changed the title (2520) implements 'manual' environment directories (PUP-2520) implements 'manual' environment directories Jun 4, 2014
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

environment misspelled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ferventcoder good catch!

Brice Figureau added 7 commits June 4, 2014 20:49
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>
@masterzen
Copy link
Contributor Author

I rebased the commits on the current master, and fixed the misspelling @ferventcoder found.

@jpartlow
Copy link
Contributor

jpartlow commented Jun 4, 2014

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).

@masterzen
Copy link
Contributor Author

@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 environment_timeout is set to a numerical value, is that right?

@zaphod42
Copy link
Contributor

zaphod42 commented Jun 4, 2014

@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.

@masterzen
Copy link
Contributor Author

@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 :)

@jpartlow
Copy link
Contributor

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.

@jpartlow jpartlow closed this Jun 11, 2014
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.

7 participants