Skip to content

Commit

Permalink
WIP (sensu#735) Fix sensu-server-enterprise Vagrant VM
Browse files Browse the repository at this point in the history
Without this patch the sensu-enterprise server is quickly crashing with a JVM
out of memory error when started inside the sensu-server-enterprise VM.

This patch addresses the problem by bumping up the allocated RAM for the VM
from 512m to 768m while also bringing down the JVM heap size from 2GB to 256m.

Resolves sensu#735
  • Loading branch information
jeffmccune committed Jul 12, 2017
1 parent 422a6d2 commit 919f8d1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 40 deletions.
69 changes: 37 additions & 32 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,43 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
server.vm.provision :shell, :path => "tests/rabbitmq.sh"
end

# This system is meant to be started without 'sensu-server' running.
config.vm.define "sensu-server-puppet5", autostart: false do |server|
server.vm.box = "centos/7"
server.vm.hostname = 'sensu-server.example.com'
server.vm.network :private_network, ip: "192.168.56.10"
server.vm.network :forwarded_port, guest: 4567, host: 4567, auto_correct: true
server.vm.network :forwarded_port, guest: 3000, host: 3000, auto_correct: true
server.vm.network :forwarded_port, guest: 15672, host: 15672, auto_correct: true
server.vm.provision :shell, :path => "tests/provision_basic_el_puppet5.sh"
server.vm.provision :shell, :path => "tests/provision_server.sh"
server.vm.provision :shell, :path => "tests/rabbitmq.sh"
end

# sensu-server-enterprise is meant to be started without 'sensu-server'
# running.
config.vm.define 'sensu-server-enterprise', autostart: false do |server|
# Sensu Enterprise runs the JVM. If the API does not start, look for OOM
# errors in `/var/log/sensu/sensu-enterprise.log` as a possible cause.
server.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--memory', '768']
end
server.vm.box = 'centos/7'
server.vm.hostname = 'sensu-server.example.com'
server.vm.network :private_network, ip: '192.168.56.10'
server.vm.network :forwarded_port, guest: 4567, host: 4567, auto_correct: true
server.vm.network :forwarded_port, guest: 4568, host: 4568, auto_correct: true
server.vm.network :forwarded_port, guest: 15672, host: 15672, auto_correct: true
server.vm.provision :shell, :path => 'tests/provision_basic_el.sh'
server.vm.provision :shell,
:path => 'tests/provision_enterprise_server.sh',
:env => {
'FACTER_SE_USER' => ENV['FACTER_SE_USER'].to_s,
'FACTER_SE_PASS' => ENV['FACTER_SE_PASS'].to_s,
}
server.vm.provision :shell, :path => 'tests/rabbitmq.sh'
end

config.vm.define "el7-client", autostart: true do |client|
client.vm.box = "centos/7"
client.vm.hostname = 'el7-client.example.com'
Expand Down Expand Up @@ -127,36 +164,4 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
client.vm.provision :shell, :path => "tests/provision_basic_debian.sh"
client.vm.provision :shell, :inline => "puppet apply /vagrant/tests/sensu-client.pp"
end

# This system is meant to be started without 'sensu-server' running.
config.vm.define "sensu-server-enterprise", autostart: false do |server|
server.vm.box = "centos/7"
server.vm.hostname = 'sensu-server.example.com'
server.vm.network :private_network, ip: "192.168.56.10"
server.vm.network :forwarded_port, guest: 4567, host: 4567, auto_correct: true
server.vm.network :forwarded_port, guest: 3000, host: 3000, auto_correct: true
server.vm.network :forwarded_port, guest: 15672, host: 15672, auto_correct: true
server.vm.provision :shell, :path => "tests/provision_basic_el.sh"
server.vm.provision :shell,
:path => "tests/provision_enterprise_server.sh",
:env => {
'FACTER_SE_USER' => ENV['FACTER_SE_USER'].to_s,
'FACTER_SE_PASS' => ENV['FACTER_SE_PASS'].to_s,
}

server.vm.provision :shell, :path => "tests/rabbitmq.sh"
end

# This system is meant to be started without 'sensu-server' running.
config.vm.define "sensu-server-puppet5", autostart: false do |server|
server.vm.box = "centos/7"
server.vm.hostname = 'sensu-server.example.com'
server.vm.network :private_network, ip: "192.168.56.10"
server.vm.network :forwarded_port, guest: 4567, host: 4567, auto_correct: true
server.vm.network :forwarded_port, guest: 3000, host: 3000, auto_correct: true
server.vm.network :forwarded_port, guest: 15672, host: 15672, auto_correct: true
server.vm.provision :shell, :path => "tests/provision_basic_el_puppet5.sh"
server.vm.provision :shell, :path => "tests/provision_server.sh"
server.vm.provision :shell, :path => "tests/rabbitmq.sh"
end
end
24 changes: 16 additions & 8 deletions tests/provision_enterprise_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,34 @@ if [ -z "${FACTER_SE_USER:-}" ]; then
fi
echo "FACTER_SE_USER=$FACTER_SE_USER"

# Save the enterprise username and password, make them work with sudo so that
# the following works:
# vagrant ssh sensu-server-enterprise
# sudo puppet apply /vagrant/test/sensu-server-enterprise.pp
scratch="$(mktemp -d)"
finish() {
[ -e "${scratch:-}" ] && rm -rf "$scratch"
}
trap finish EXIT
TMPDIR="$scratch"
profile="$(mktemp)"

cat > ~/.bash_profile <<'EOF'
cat > "$profile" <<'EOF'
[ -f ~/.bashrc ] && source ~/.bashrc
export PATH=$PATH:$HOME/.local/bin:$HOME/bin
# Pass these two key facts through sudo invocations to puppet
# Pass these two facts through vagrant sudo invocations to puppet
alias sudo='sudo FACTER_SE_USER=$FACTER_SE_USER FACTER_SE_PASS=$FACTER_SE_PASS'
EOF
cat >> ~/.bash_profile <<EOF
cat >> "$profile" <<EOF
export FACTER_SE_USER='${FACTER_SE_USER}'
export FACTER_SE_PASS='${FACTER_SE_PASS}'
EOF

# install the updated profile in vagrant's home.
install -o vagrant -g vagrant -m 0644 "$profile" ~vagrant/.bash_profile

# setup module dependencies
puppet module install puppetlabs/rabbitmq

# inifile is used to tune the JVM heap size in Vagrant
puppet module install puppetlabs/inifile

# install dependencies for sensu
yum -y install redis jq nagios-plugins-ntp
systemctl start redis
Expand All @@ -34,4 +43,3 @@ systemctl enable redis
# run puppet
puppet apply /vagrant/tests/rabbitmq.pp
puppet apply /vagrant/tests/sensu-server-enterprise.pp
puppet apply /vagrant/tests/uchiwa.pp
15 changes: 15 additions & 0 deletions tests/sensu-server-enterprise.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
node 'sensu-server' {

Ini_setting {
ensure => present,
path => '/etc/default/sensu',
key_val_separator => '=',
show_diff => true,
require => Package['sensu-enterprise'],
notify => Service['sensu-enterprise'],
}

file { 'api.keystore':
ensure => 'file',
path => '/etc/sensu/api.keystore',
Expand Down Expand Up @@ -65,4 +74,10 @@
contacts => ['ops', 'support'],
subscribers => 'sensu-test',
}

# Tune the JVM Heap size for Sensu Enterprise on Vagrant
ini_setting { 'Sensu JVM Heap Size':
setting => 'HEAP_SIZE',
value => '"256m"',
}
}

0 comments on commit 919f8d1

Please sign in to comment.