-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Redis will be used for rate limiting and (at a later point in time) also for metrics. - The monit process will only be started if either the Puma webserver is used or 'cc.experimental.use_redis' is set to 'true' (defaults to 'false'). - If Redis is used, the CC config 'redis.socket' is set; this switches the rate limit implementation from using in-memory counters to Redis.
- Loading branch information
1 parent
e3b27c6
commit 5344ad7
Showing
14 changed files
with
227 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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,14 @@ | ||
<% | ||
cloud_controller_internal = link("cloud_controller_internal") | ||
if cloud_controller_internal.p("cc.experimental.use_puma_webserver") || cloud_controller_internal.p("cc.experimental.use_redis") | ||
%> | ||
|
||
check process redis | ||
with pidfile /var/vcap/sys/run/bpm/redis/redis.pid | ||
start program "/var/vcap/jobs/bpm/bin/bpm start redis" | ||
stop program "/var/vcap/jobs/bpm/bin/bpm stop redis" | ||
group vcap | ||
|
||
<% | ||
end | ||
%> |
This file contains 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,18 @@ | ||
--- | ||
name: redis | ||
|
||
description: "Co-deployed Redis used for rate limiting and metrics" | ||
|
||
templates: | ||
bpm.yml.erb: config/bpm.yml | ||
pre-start.sh.erb: bin/pre-start.sh | ||
redis-cli.sh.erb: bin/redis-cli.sh | ||
|
||
packages: | ||
- redis | ||
|
||
consumes: | ||
- name: cloud_controller_internal | ||
type: cloud_controller_internal | ||
|
||
properties: {} |
This file contains 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,16 @@ | ||
--- | ||
processes: | ||
- name: redis | ||
executable: /var/vcap/packages/redis/redis-server | ||
args: | ||
- --port | ||
- 0 | ||
- --unixsocket | ||
- /var/vcap/data/redis/redis.sock | ||
- --save | ||
- "" | ||
ephemeral_disk: true | ||
limits: | ||
open_files: 10032 | ||
hooks: | ||
pre_start: /var/vcap/jobs/redis/bin/pre-start.sh |
This file contains 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,5 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
sysctl -w vm.overcommit_memory=1 |
This file contains 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,5 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
/var/vcap/packages/redis/redis-cli -s /var/vcap/data/redis/redis.sock |
This file contains 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,9 @@ | ||
redis | ||
============ | ||
Redis in-memory data store. | ||
|
||
This file can be downloaded from the following locations: | ||
|
||
| Filename | Download URL | | ||
| -------- | ------------ | | ||
| 7.0.11.tar.gz | https://github.com/redis/redis/archive/7.0.11.tar.gz | |
This file contains 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,16 @@ | ||
#!/bin/bash -eu | ||
|
||
function main() { | ||
local redis_version | ||
redis_version="7.0.11" | ||
|
||
tar xzf "redis/${redis_version}.tar.gz" | ||
|
||
pushd "redis-${redis_version}" > /dev/null | ||
make | ||
|
||
cp src/redis-server src/redis-cli "${BOSH_INSTALL_TARGET}" | ||
popd > /dev/null | ||
} | ||
|
||
main |
This file contains 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 @@ | ||
--- | ||
name: redis | ||
files: | ||
- redis/7.0.11.tar.gz |
This file contains 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 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 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,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rspec' | ||
require 'bosh/template/test' | ||
|
||
module Bosh | ||
module Template | ||
module Test | ||
describe 'redis job template rendering' do | ||
let(:release_path) { File.join(File.dirname(__FILE__), '../..') } | ||
let(:release) { ReleaseDir.new(release_path) } | ||
let(:job) { release.job('redis') } | ||
let(:spec) { job.instance_variable_get(:@spec) } | ||
let(:job_path) { job.instance_variable_get(:@job_path) } | ||
let(:cc_internal_properties) { { 'cc' => { 'experimental' => { 'use_puma_webserver' => false, 'use_redis' => false } } } } | ||
let(:link) { Link.new(name: 'cloud_controller_internal', properties: cc_internal_properties) } | ||
|
||
describe 'monit' do | ||
let(:template) { Template.new(spec, File.join(job_path, 'monit')) } | ||
|
||
context 'when the puma webserver is used' do | ||
it 'renders the monit directives' do | ||
cc_internal_properties['cc']['experimental']['use_puma_webserver'] = true | ||
result = template.render({}, consumes: [link]) | ||
expect(result).to include('check process redis') | ||
end | ||
end | ||
|
||
context "when 'cc.experimental.use_redis' is set to 'true'" do | ||
it 'renders the monit directives' do | ||
cc_internal_properties['cc']['experimental']['use_redis'] = true | ||
result = template.render({}, consumes: [link]) | ||
expect(result).to include('check process redis') | ||
end | ||
end | ||
|
||
context "when neither the puma webserver is used nor 'cc.experimental.use_redis' is set to 'true'" do | ||
it 'does not render the monit directives' do | ||
result = template.render({}, consumes: [link]) | ||
expect(result.strip).to eq('') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |