Skip to content

Commit

Permalink
Merge pull request #688 from chef/jd/expiry-intervals
Browse files Browse the repository at this point in the history
Cookbook Caching
  • Loading branch information
joedevivo committed Feb 6, 2015
2 parents dc78b35 + 1ad5744 commit 30f4314
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Chef Server Changelog

## 12.0.4 (unreleased)

### opscode-omnibus
* nginx bookshelf caching, enabled with
`opscode_erchef['nginx_bookshelf_caching'] = :on`
* s3 URL expiry window setting,
`opscode_erchef['s3_url_expiry_window_size']`, which can have values
in minutes (e.g. `"15m"`), percentage (e.g. `"15%"`), or just be
`:off`.

### oc\_erchef 1.2.2
* Add `s3_url_expiry_window_size` setting for s3 URL caching

## 12.0.3 (2015-02-04)

### enterprise-chef-common 0.5.1
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
GIT
remote: git://github.com/opscode/omnibus-software.git
revision: 2e950057973496873f002275ab8d99a3fd87e461
revision: f9460a7abacba68033374cb98ffaa65bb9ef478d
specs:
omnibus-software (4.0.0)

GIT
remote: git://github.com/opscode/omnibus.git
revision: bc48821bb4a69cd6b6d587a28b81d2d1c7c684b9
revision: e1d5d221dd3ea84d19cbb9eec5ce1094501d375b
specs:
omnibus (4.0.0)
chef-sugar (~> 2.2)
Expand Down
2 changes: 1 addition & 1 deletion config/software/bookshelf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

name "bookshelf"
default_version "1.1.4"
default_version "1.1.5"

source git: "git://github.com/opscode/bookshelf.git"

Expand Down
2 changes: 1 addition & 1 deletion config/software/oc_erchef.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

name "oc_erchef"
default_version "1.2.0"
default_version "1.2.2"

source git: "git@github.com:opscode/oc_erchef"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
default['private_chef']['opscode-erchef']['base_resource_url'] = :host_header
default['private_chef']['opscode-erchef']['s3_bucket'] = 'bookshelf'
default['private_chef']['opscode-erchef']['s3_url_ttl'] = 28800
default['private_chef']['opscode-erchef']['nginx_bookshelf_caching'] = :off
default['private_chef']['opscode-erchef']['s3_url_expiry_window_size'] = :off
default['private_chef']['opscode-erchef']['s3_parallel_ops_timeout'] = 5000
default['private_chef']['opscode-erchef']['s3_parallel_ops_fanout'] = 20
default['private_chef']['opscode-erchef']['authz_timeout'] = 2000
Expand Down
11 changes: 11 additions & 0 deletions files/private-chef-cookbooks/private-chef/libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ def erl_atom_or_string(term)
self.class.erl_atom_or_string(term)
end

def s3_url_caching(setting)
case setting.to_s
when "off"
"off"
when /m$/
"{#{setting.chop}, minutes}"
when /%$/
"{#{setting.chop}, percent}"
end
end

# OC-11540, fallback to ssl_port if non_ssl_port is disabled
def internal_lb_url
if node['private_chef']['nginx']['non_ssl_port'] == false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ http {

# external lb config for Chef API
<%- if node['private_chef']['lb']['enable'] -%>
proxy_cache_path <%= File.join(@dir, "cache") %> levels=1:2 keys_zone=webui-cache:50m max_size=<%= @cache_max_size %> inactive=600m;
proxy_cache_path <%= File.join(@dir, "cache", "webui") %> levels=1:2 keys_zone=webui-cache:50m max_size=<%= @cache_max_size %> inactive=600m;
proxy_cache_path <%= File.join(@dir, "cache", "cookbooks") %> levels=1:2 keys_zone=cookbooks:50m max_size=<%= @cache_max_size %> inactive=600m;
proxy_temp_path <%= File.join(@dir, "cache-tmp") %>;

# We support three options: serve nothing on non_ssl_port (80),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,29 @@
}

# bookshelf
<% if node['private_chef']['opscode-erchef']['nginx_bookshelf_caching'] != :off -%>
location ~ "/<%= node['private_chef']['opscode-erchef']['s3_bucket'] %>/{0,1}.*$" {
set $destination @cached;
if ($request_method !~ ^(GET)$) {
set $destination @uncached;
}
error_page 404 = $destination;
return 404;
}
location @cached {
proxy_cache cookbooks;
more_clear_headers 'Cache-Control';
add_header X-Proxy-Cache $upstream_cache_status;
proxy_pass http://bookshelf;
}
location @uncached {
proxy_pass http://bookshelf;
}
<% else -%>
location ~ "/<%= node['private_chef']['opscode-erchef']['s3_bucket'] %>/{0,1}.*$" {
proxy_pass http://bookshelf;
}
<% end -%>

# erchef status endpoint
location ~ "^/_status/?$" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
{s3_external_url, <%= @helper.erl_atom_or_string(node['private_chef']['bookshelf']['external_url']) %>},
{s3_platform_bucket_name, "<%= node['private_chef']['opscode-erchef']['s3_bucket'] %>"},
{s3_url_ttl, <%= node['private_chef']['opscode-erchef']['s3_url_ttl'] %>},
{s3_url_expiry_window_size, <%= @helper.s3_url_caching(node['private_chef']['opscode-erchef']['s3_url_expiry_window_size']) %>},
{s3_parallel_ops_timeout, <%= node['private_chef']['opscode-erchef']['s3_parallel_ops_timeout'] %>},
{s3_parallel_ops_fanout, <%= node['private_chef']['opscode-erchef']['s3_parallel_ops_fanout'] %>},
{depsolver_timeout, <%= @depsolver_timeout %>}
Expand Down

0 comments on commit 30f4314

Please sign in to comment.