-
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
Closed
masterzen
wants to merge
7
commits into
puppetlabs:master
from
masterzen:feature/2520-refresh-env-on-demand
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
81aa46a
(2520) environment.conf ttl settings supports "manual"
3310fa8
(2520) MemoryFile support a minimal stat operation
9608385
(2520) MemoryFile implementation of touch
59e062a
(2520) Environment loaders now supports get_environment_dir
d6f19a6
(2520) Implements manual directory environments
eef0cd1
(2520) support TTL unmunging for displaying the original value
f383aa3
(2520) add a face to list environments and flush 'manual' ones
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'puppet/application/face_base' | ||
|
||
class Puppet::Application::Environment < Puppet::Application::FaceBase | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
require 'puppet/face' | ||
|
||
Puppet::Face.define(:environment, '0.0.1') do | ||
copyright "Puppet Labs", 2014 | ||
license "Apache 2 license; see COPYING" | ||
|
||
summary "Provides interaction with directory environments." | ||
description <<-EOT | ||
This command helps with management of directory based environments, notably listing them or flushing the puppet master | ||
internal cache of directory environments set to 'manual'. | ||
EOT | ||
|
||
action :list do | ||
summary "List all directory environments." | ||
returns "the list of all directory environments" | ||
description <<-EOT | ||
Lists all directory environments. | ||
EOT | ||
examples <<-EOT | ||
Lists all directory environments: | ||
|
||
$ puppet environment list | ||
EOT | ||
|
||
option "--details" do | ||
summary "displays more information about the listed environments" | ||
end | ||
|
||
when_invoked do |options| | ||
setup_environments do | ||
Puppet.lookup(:environments).list.each do |env| | ||
unless options[:details] | ||
puts env.name | ||
else | ||
unless Puppet.lookup(:environments).get_environment_dir(env.name).nil? | ||
conf = Puppet.lookup(:environments).get_conf(env.name) | ||
puts "#{env.name} (timeout: #{Puppet::Settings::TTLSetting.unmunge(conf.environment_timeout, 'environment_timeout')}, manifest: #{conf.manifest}, modulepath: #{conf.modulepath})" | ||
end | ||
end | ||
end | ||
end | ||
nil | ||
end | ||
end | ||
|
||
action :flush do | ||
summary "Flushes the cache of directory environments set to 'manual'." | ||
arguments "[<environment> [<environment> ...]]" | ||
returns "Nothing." | ||
description <<-EOT | ||
Flushes the given environment cache. With --all it is possible to flush all directory environments. | ||
EOT | ||
examples <<-EOT | ||
Manually flush the usdatacenter environment: | ||
|
||
$ puppet environment flush usdatacenter | ||
|
||
Manually flush all environments: | ||
|
||
$ puppet environment flush --all | ||
|
||
Manually flush several environments: | ||
|
||
$ puppet environment flush env1 env2 env3 | ||
EOT | ||
|
||
option "--all" do | ||
summary "force all directory environments set to 'manual' to be invalidated" | ||
end | ||
|
||
when_invoked do |*args| | ||
options = args.pop | ||
name = args | ||
|
||
setup_environments do | ||
envs = options[:all] ? Puppet.lookup(:environments).list.map(&:name) : [name].flatten | ||
envs.each do |envname| | ||
if dir = Puppet.lookup(:environments).get_environment_dir(envname) | ||
Puppet::FileSystem.touch(dir) | ||
end | ||
end | ||
end | ||
nil | ||
end | ||
end | ||
|
||
def setup_environments | ||
# pretend we're the master | ||
master_section = Puppet.settings.values(nil, :master) | ||
|
||
loader_settings = { | ||
:environmentpath => master_section.interpolate(:environmentpath), | ||
:basemodulepath => master_section.interpolate(:basemodulepath), | ||
} | ||
Puppet.override(Puppet.base_context(loader_settings), | ||
"New environment loaders generated from the requested section.") do | ||
yield | ||
end | ||
end | ||
|
||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
mtime would likely be more accurate, no?
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.
See #2638 (comment) for the rationale on ctime versus mtime :)
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.
Oh, I see. Good to know there is a strong rationale.