Skip to content

Commit

Permalink
Replacing SystemD and Sys V on Beaker on Docker
Browse files Browse the repository at this point in the history
Using System V and SystemD init systems is not ideal. They tend to
interfere heavily with host's own init systems - processes are going
bad, uses 100% CPU, or just crush. That's because thay are run in
privileged mode.

This commit tries to fix that be switching over to replacements of those
init systems. For System V, that's custom supervisord running SSH, and
for SystemD that's gdraheim/docker-systemctl-replacement python script.

GitHub issue: #104
  • Loading branch information
cardil committed Sep 14, 2018
1 parent 951c1d3 commit 31b21bf
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 162 deletions.
10 changes: 0 additions & 10 deletions lib/puppet_x/coi/jboss/hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ def delete(key)
super
end

def ordered_keys
@keys ||= []
end

def each_in_order(&_block)
ordered_keys.each do |key|
yield(key, self[key])
end
end

def each_sorted(&_block)
keys.map(&:to_s).sort.each do |key|
yield(key, self[key])
Expand Down
7 changes: 4 additions & 3 deletions manifests/internal/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
anchor { 'jboss::service::begin': }

# TODO: change to $::virtual after dropping support for Puppet 2.x
$enable = $::jboss_virtual ? {
'docker' => undef,
default => true,
if $::jboss_virtual == 'docker' and $jboss::internal::compatibility::initsystem == 'SystemV' {
$enable = undef
} else {
$enable = true
}

if $jboss::internal::compatibility::initsystem == 'SystemD' {
Expand Down
7 changes: 5 additions & 2 deletions spec/acceptance/nodesets/centos-6-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ HOSTS:
platform: el-6-x86_64
hypervisor: docker
image: centos:6
docker_cmd: '["/sbin/init"]'
docker_cmd: '["/usr/local/sbin/supervisord-nodaemon.sh"]'
docker_preserve_image: true
docker_image_commands:
- 'cp /bin/true /sbin/mingetty' # Fix for getty 100% cpu -> https://github.com/moby/moby/issues/4040
- "sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf"
- 'yum install -y crontabs wget tar centos-release-scl'
- 'yum install -y python27-python-pip'
- 'scl enable python27 "pip install puppeter"'
- 'curl -L https://bit.ly/2CPhtbe | bash -e'
dockeropts:
HostConfig:
Privileged: false
mount_folders:
wget_cache:
host_path: /tmp/docker-cache/wget
Expand Down
7 changes: 5 additions & 2 deletions spec/acceptance/nodesets/centos-6-pe288-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ HOSTS:
platform: el-6-x86_64
hypervisor: docker
image: centos:6
docker_cmd: '["/sbin/init"]'
docker_cmd: '["/usr/local/sbin/supervisord-nodaemon.sh"]'
docker_preserve_image: true
docker_image_commands:
- 'cp /bin/true /sbin/mingetty'
- "sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf"
- 'yum install -y crontabs wget tar'
- 'curl -L https://bit.ly/2CPhtbe | bash -e'
dockeropts:
HostConfig:
Privileged: false
roles:
- agent
- master
Expand Down
7 changes: 6 additions & 1 deletion spec/acceptance/nodesets/centos-7-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ HOSTS:
hypervisor : docker
image: centos:7
docker_preserve_image: true
docker_cmd: ["/sbin/init"]
docker_cmd: '["/bin/systemctl"]'
docker_image_commands:
- 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts python-pip'
- 'curl -L https://bit.ly/2p44vg4 > /bin/systemctl'
- mkdir -p /run/systemd/system
dockeropts:
HostConfig:
Privileged: false
mount_folders:
wget_cache:
host_path: /tmp/docker-cache/wget
Expand Down
8 changes: 6 additions & 2 deletions spec/acceptance/nodesets/debian-8-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ HOSTS:
hypervisor: docker
image: debian:8
docker_preserve_image: true
docker_cmd: ["/bin/systemd"]
docker_cmd: '["/bin/systemctl"]'
docker_image_commands:
- apt-get install -y wget net-tools python-pip python-dev
- rm /lib/systemd/system/getty.target
- 'curl -L https://bit.ly/2p44vg4 > /bin/systemctl'
- mkdir -p /run/systemd/system
dockeropts:
HostConfig:
Privileged: false
mount_folders:
wget_cache:
host_path: /tmp/wget_cache
Expand Down
8 changes: 6 additions & 2 deletions spec/acceptance/nodesets/debian-9-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ HOSTS:
hypervisor: docker
image: debian:9
docker_preserve_image: true
docker_cmd: ["/bin/systemd"]
docker_cmd: '["/bin/systemctl"]'
docker_image_commands:
- apt-get install -y wget net-tools python-pip python-dev
- rm /lib/systemd/system/getty.target
- 'curl -L https://bit.ly/2p44vg4 > /bin/systemctl'
- mkdir -p /run/systemd/system
dockeropts:
HostConfig:
Privileged: false
mount_folders:
wget_cache:
host_path: /tmp/wget_cache
Expand Down
8 changes: 5 additions & 3 deletions spec/acceptance/nodesets/ubuntu-1404-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ HOSTS:
hypervisor: docker
image: ubuntu:14.04
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_cmd: '["/usr/local/sbin/supervisord-nodaemon.sh"]'
docker_image_commands:
- 'rm /usr/sbin/policy-rc.d'
- 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl'
- 'apt-get install -y net-tools wget python-pip python-dev'
- 'locale-gen en_US.UTF-8'
- 'curl -L https://bit.ly/2CPhtbe | bash -e'
dockeropts:
HostConfig:
Privileged: false
mount_folders:
wget_cache:
host_path: /tmp/docker-cache/wget
Expand Down
7 changes: 6 additions & 1 deletion spec/acceptance/nodesets/ubuntu-1604-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ HOSTS:
hypervisor: docker
image: ubuntu:16.04
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_cmd: '["/bin/systemctl"]'
docker_image_commands:
- 'apt-get install -y net-tools wget locales python-pip python-dev'
- 'locale-gen en_US.UTF-8'
- 'curl -L https://bit.ly/2p44vg4 > /bin/systemctl'
- mkdir -p /run/systemd/system
dockeropts:
HostConfig:
Privileged: false
mount_folders:
wget_cache:
host_path: /tmp/docker-cache/wget
Expand Down
136 changes: 0 additions & 136 deletions spec/classes/internal/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,140 +99,4 @@
end
end
end

# describe 'on RedHat os family' do
# describe 'release 6.7' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.oraclelinux_facts
# end
# it_behaves_like 'as a invalid Java-JBoss configuration'
# end
# describe 'release 7.4' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.oraclelinux_facts(
# :operatingsystemrelease => '7.4',
# :operatingsystemmajrelease => '7'
# )
# end
# it_behaves_like 'as a valid Java-JBoss configuration'
# end
# describe 'on Docker container' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.oraclelinux_facts(
# :jboss_virtual => 'docker'
# )
# end
# it_behaves_like 'containg service anchors'
# it_behaves_like 'containg service restart exec'
# it_behaves_like 'containg class structure'
# it do
# is_expected.to contain_service('wildfly').
# with(
# :ensure => 'running',
# :enable => nil,
# :hasstatus => true,
# :hasrestart => true
# )
# end
# describe 'on SystemD system' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.oraclelinux_facts(
# :jboss_virtual => 'docker',
# :operatingsystemrelease => '7.1'
# )
# end
# it_behaves_like 'containg SystemD execs'
# end
# end
# describe 'on non-Docker machine' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.oraclelinux_facts(
# :jboss_virtual => 'phisycal'
# )
# end
# it_behaves_like 'containg service anchors'
# it_behaves_like 'containg service restart exec'
# it_behaves_like 'containg class structure'
# it do
# is_expected.to contain_service('wildfly').
# with(
# :ensure => 'running',
# :enable => true,
# :hasstatus => true,
# :hasrestart => true
# )
# end
# describe 'on SystemD system' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.oraclelinux_facts(
# :jboss_virtual => 'phisycal',
# :operatingsystemrelease => '7.1'
# )
# end
# it_behaves_like 'containg SystemD execs'
# end
# end
# end

# describe 'on Debian os family' do
# let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts }
# it_behaves_like 'as a valid Java-JBoss configuration'
# describe 'on Docker container' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.ubuntu_facts(
# :jboss_virtual => 'docker'
# )
# end
# it_behaves_like 'containg service anchors'
# it_behaves_like 'containg service restart exec'
# it_behaves_like 'containg class structure'
# it do
# is_expected.to contain_service('wildfly').
# with(
# :ensure => 'running',
# :enable => nil,
# :hasstatus => true,
# :hasrestart => true
# )
# end
# describe 'on SystemD system' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.ubuntu_facts(
# :jboss_virtual => 'docker',
# :operatingsystem => 'Debian',
# :operatingsystemrelease => '8'
# )
# end
# it_behaves_like 'containg SystemD execs'
# end
# end
# describe 'on non-Docker machine' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.ubuntu_facts(
# :jboss_virtual => 'vmware'
# )
# end
# it_behaves_like 'containg service anchors'
# it_behaves_like 'containg service restart exec'
# it_behaves_like 'containg class structure'
# it do
# is_expected.to contain_service('wildfly').
# with(
# :ensure => 'running',
# :enable => true,
# :hasstatus => true,
# :hasrestart => true
# )
# end
# describe 'on SystemD system' do
# let(:facts) do
# Testing::RspecPuppet::SharedFacts.ubuntu_facts(
# :jboss_virtual => 'vmware',
# :operatingsystemrelease => '16.04'
# )
# end
# it_behaves_like 'containg SystemD execs'
# end
# end
# end
end

0 comments on commit 31b21bf

Please sign in to comment.