diff options
author | Michael Polenchuk <mpolenchuk@mirantis.com> | 2017-03-09 14:06:18 +0400 |
---|---|---|
committer | Michael Polenchuk <mpolenchuk@mirantis.com> | 2017-03-21 11:35:46 +0000 |
commit | 4f33d4aabb859894167728ec347ee36b2c17d19d (patch) | |
tree | acb8f7b28679a8c92d1a504b800269c0248f66fa | |
parent | 77320dedde7925d95e2217436369de0353824c12 (diff) |
Conform cgroups to systemd based services
Update cgroups configuration to be running on ubuntu 16.04.
Remove "cgroup-lite" package/service since systemd
mounts cgroups sanely itself.
Change-Id: I250f1ba92fbe1ceac415a73b640fd00d6e2898e4
Closes-Bug: #1669747
Notes
Notes (review):
Code-Review+1: Igor Gajsin <igajsin@mirantis.com>
Verified+1: Fuel CI <fuel-ci-bot@mirantis.com>
Code-Review+2: Vladimir Kuklin <vkuklin@mirantis.com>
Code-Review+1: Stanislaw Bogatkin <sbogatkin@mirantis.com>
Code-Review+1: Oleksiy Molchanov <omolchanov@mirantis.com>
Workflow+1: Denis Egorenko <degorenko@mirantis.com>
Verified+2: Jenkins
Submitted-by: Jenkins
Submitted-at: Mon, 27 Mar 2017 10:59:51 +0000
Reviewed-on: https://review.openstack.org/443556
Project: openstack/fuel-library
Branch: refs/heads/master
6 files changed, 89 insertions, 45 deletions
diff --git a/deployment/puppet/cgroups/files/cgconfig.init b/deployment/puppet/cgroups/files/cgconfig.init new file mode 100644 index 0000000..cc84fdd --- /dev/null +++ b/deployment/puppet/cgroups/files/cgconfig.init | |||
@@ -0,0 +1,66 @@ | |||
1 | #!/bin/sh | ||
2 | ### BEGIN INIT INFO | ||
3 | # Provides: cgconfig | ||
4 | # Required-Start: $remote_fs $syslog | ||
5 | # Required-Stop: $remote_fs $syslog | ||
6 | # Should-Start: | ||
7 | # Should-Stop: | ||
8 | # Default-Start: 2 3 4 5 | ||
9 | # Default-Stop: 0 1 6 | ||
10 | # Short-Description: Configures CGroups | ||
11 | ### END INIT INFO | ||
12 | |||
13 | start_service() { | ||
14 | if is_running; then | ||
15 | echo "cgrulesengd is running already!" | ||
16 | return 1 | ||
17 | else | ||
18 | echo "Processing /etc/cgconfig.conf ..." | ||
19 | cgconfigparser -l /etc/cgconfig.conf | ||
20 | echo "Processing /etc/cgrules.conf ..." | ||
21 | cgrulesengd -vvv --logfile=/var/log/cgrulesengd.log | ||
22 | return 0 | ||
23 | fi | ||
24 | } | ||
25 | |||
26 | stop_service() { | ||
27 | if is_running; then | ||
28 | echo "Stopping cgrulesengd ..." | ||
29 | pkill cgrulesengd | ||
30 | else | ||
31 | echo "cgrulesengd is not running!" | ||
32 | return 1 | ||
33 | fi | ||
34 | } | ||
35 | |||
36 | status() { | ||
37 | if pgrep cgrulesengd > /dev/null; then | ||
38 | echo "cgrulesengd is running" | ||
39 | return 0 | ||
40 | else | ||
41 | echo "cgrulesengd is not running!" | ||
42 | return 3 | ||
43 | fi | ||
44 | } | ||
45 | |||
46 | is_running() { | ||
47 | status >/dev/null 2>&1 | ||
48 | } | ||
49 | |||
50 | case "${1:-}" in | ||
51 | start) | ||
52 | start_service | ||
53 | ;; | ||
54 | stop) | ||
55 | stop_service | ||
56 | ;; | ||
57 | status) | ||
58 | status | ||
59 | ;; | ||
60 | *) | ||
61 | echo "Usage: /etc/init.d/cgconfig {start|stop|restart|status}" | ||
62 | exit 2 | ||
63 | ;; | ||
64 | esac | ||
65 | |||
66 | exit $? | ||
diff --git a/deployment/puppet/cgroups/manifests/init.pp b/deployment/puppet/cgroups/manifests/init.pp index ba31ec7..52a1f90 100644 --- a/deployment/puppet/cgroups/manifests/init.pp +++ b/deployment/puppet/cgroups/manifests/init.pp | |||
@@ -13,51 +13,40 @@ | |||
13 | class cgroups( | 13 | class cgroups( |
14 | $cgroups_set = {}, | 14 | $cgroups_set = {}, |
15 | $packages = $cgroups::params::packages, | 15 | $packages = $cgroups::params::packages, |
16 | ) | 16 | ) inherits cgroups::params { |
17 | inherits cgroups::params | 17 | |
18 | { | ||
19 | validate_hash($cgroups_set) | 18 | validate_hash($cgroups_set) |
20 | ensure_packages($packages, { tag => 'cgroups' }) | 19 | ensure_packages($packages, { tag => 'cgroups' }) |
21 | 20 | ||
22 | |||
23 | File { | 21 | File { |
24 | ensure => file, | 22 | ensure => file, |
25 | owner => 'root', | 23 | owner => 'root', |
26 | group => 'root', | 24 | group => 'root', |
27 | mode => '0644', | 25 | mode => '0644', |
26 | notify => Service['cgconfig'], | ||
28 | } | 27 | } |
29 | 28 | ||
30 | file { '/etc/cgconfig.conf': | 29 | file { '/etc/cgconfig.conf': |
31 | content => template('cgroups/cgconfig.conf.erb'), | 30 | content => template('cgroups/cgconfig.conf.erb'), |
32 | notify => Service['cgconfigparser'], | ||
33 | tag => 'cgroups', | 31 | tag => 'cgroups', |
34 | } | 32 | } |
35 | 33 | ||
36 | file { '/etc/cgrules.conf': | 34 | file { '/etc/cgrules.conf': |
37 | content => template('cgroups/cgrules.conf.erb'), | 35 | content => template('cgroups/cgrules.conf.erb'), |
38 | notify => Service['cgrulesengd'], | ||
39 | tag => 'cgroups', | 36 | tag => 'cgroups', |
40 | } | 37 | } |
41 | 38 | ||
39 | file { '/etc/init.d/cgconfig': | ||
40 | mode => '0755', | ||
41 | source => "puppet:///modules/${module_name}/cgconfig.init", | ||
42 | tag => 'cgroups', | ||
43 | } | ||
44 | |||
42 | class { '::cgroups::service': | 45 | class { '::cgroups::service': |
43 | cgroups_settings => $cgroups_set, | 46 | cgroups_settings => $cgroups_set, |
44 | } | 47 | } |
45 | 48 | ||
46 | Package <| tag == 'cgroups' |> ~> | 49 | Package <| tag == 'cgroups' |> -> File <| tag == 'cgroups' |> |
47 | Service['cgrulesengd'] | 50 | Service['cgconfig'] -> Cgclassify <||> |
48 | |||
49 | Package <| tag == 'cgroups' |> -> | ||
50 | File <| tag == 'cgroups' |> | ||
51 | |||
52 | File <| tag == 'cgroups' |> -> | ||
53 | Service['cgroup-lite'] | ||
54 | |||
55 | Service['cgroup-lite'] -> | ||
56 | Service['cgconfigparser'] | ||
57 | |||
58 | Service['cgconfigparser'] -> | ||
59 | Cgclassify <||> | ||
60 | 51 | ||
61 | Cgclassify <||> -> | ||
62 | Service['cgrulesengd'] | ||
63 | } | 52 | } |
diff --git a/deployment/puppet/cgroups/manifests/params.pp b/deployment/puppet/cgroups/manifests/params.pp index 1e3d9c9..db76f5d 100644 --- a/deployment/puppet/cgroups/manifests/params.pp +++ b/deployment/puppet/cgroups/manifests/params.pp | |||
@@ -2,10 +2,11 @@ class cgroups::params { | |||
2 | 2 | ||
3 | case $::osfamily { | 3 | case $::osfamily { |
4 | 'Debian': { | 4 | 'Debian': { |
5 | $packages = ['cgroup-bin', 'libcgroup1', 'cgroup-upstart'] | 5 | $packages = ['cgroup-bin', 'libcgroup1'] |
6 | } | 6 | } |
7 | default: { | 7 | default: { |
8 | fail("Unsupported platform") | 8 | fail("Unsupported platform") |
9 | } | 9 | } |
10 | } | 10 | } |
11 | |||
11 | } | 12 | } |
diff --git a/deployment/puppet/cgroups/manifests/service.pp b/deployment/puppet/cgroups/manifests/service.pp index 51506df..44d691e 100644 --- a/deployment/puppet/cgroups/manifests/service.pp +++ b/deployment/puppet/cgroups/manifests/service.pp | |||
@@ -1,26 +1,16 @@ | |||
1 | class cgroups::service ( | 1 | class cgroups::service ( |
2 | $cgroups_settings = {}, | 2 | $cgroups_settings = {}, |
3 | ) | 3 | ) { |
4 | { | ||
5 | service { 'cgroup-lite': | ||
6 | ensure => running, | ||
7 | enable => true, | ||
8 | } | ||
9 | |||
10 | service { 'cgconfigparser': | ||
11 | ensure => running, | ||
12 | hasstatus => false, | ||
13 | status => '/bin/true', | ||
14 | restart => 'service cgconfigparser restart', | ||
15 | require => Service['cgroup-lite'], | ||
16 | } | ||
17 | 4 | ||
18 | service { 'cgrulesengd': | 5 | service { 'cgconfig': |
19 | ensure => running, | 6 | ensure => running, |
7 | enable => true, | ||
8 | provider => 'init', | ||
20 | } | 9 | } |
21 | 10 | ||
22 | $cgclass_res = map_cgclassify_opts($cgroups_settings) | 11 | $cgclass_res = map_cgclassify_opts($cgroups_settings) |
23 | unless empty($cgclass_res) { | 12 | unless empty($cgclass_res) { |
24 | create_resources('cgclassify', $cgclass_res, { 'ensure' => present }) | 13 | create_resources('cgclassify', $cgclass_res, { 'ensure' => present }) |
25 | } | 14 | } |
15 | |||
26 | } | 16 | } |
diff --git a/deployment/puppet/cgroups/spec/classes/cgroups_init_spec.rb b/deployment/puppet/cgroups/spec/classes/cgroups_init_spec.rb index eb0a945..61a04b3 100644 --- a/deployment/puppet/cgroups/spec/classes/cgroups_init_spec.rb +++ b/deployment/puppet/cgroups/spec/classes/cgroups_init_spec.rb | |||
@@ -15,6 +15,7 @@ describe 'cgroups', :type => :class do | |||
15 | :owner => 'root', | 15 | :owner => 'root', |
16 | :group => 'root', | 16 | :group => 'root', |
17 | :mode => '0644', | 17 | :mode => '0644', |
18 | :notify => 'Service[cgconfig]', | ||
18 | :tag => 'cgroups', | 19 | :tag => 'cgroups', |
19 | } | 20 | } |
20 | end | 21 | end |
@@ -27,7 +28,7 @@ describe 'cgroups', :type => :class do | |||
27 | :cgroups_settings => params[:cgroups_set]) | 28 | :cgroups_settings => params[:cgroups_set]) |
28 | } | 29 | } |
29 | 30 | ||
30 | %w(libcgroup1 cgroup-bin cgroup-upstart).each do |cg_pkg| | 31 | %w(libcgroup1 cgroup-bin).each do |cg_pkg| |
31 | it { is_expected.to contain_package(cg_pkg) } | 32 | it { is_expected.to contain_package(cg_pkg) } |
32 | end | 33 | end |
33 | 34 | ||
@@ -36,7 +37,6 @@ describe 'cgroups', :type => :class do | |||
36 | it { p catalogue.resource 'file', cg_file } | 37 | it { p catalogue.resource 'file', cg_file } |
37 | end | 38 | end |
38 | 39 | ||
39 | it { is_expected.to contain_file('/etc/cgrules.conf').that_notifies('Service[cgrulesengd]') } | 40 | it { is_expected.to contain_file('/etc/init.d/cgconfig').with(file_defaults.merge({:mode => '0755'})) } |
40 | it { is_expected.to contain_file('/etc/cgconfig.conf').that_notifies('Service[cgconfigparser]') } | ||
41 | end | 41 | end |
42 | end | 42 | end |
diff --git a/deployment/puppet/cgroups/spec/classes/cgroups_service_spec.rb b/deployment/puppet/cgroups/spec/classes/cgroups_service_spec.rb index ea39a3a..2519815 100644 --- a/deployment/puppet/cgroups/spec/classes/cgroups_service_spec.rb +++ b/deployment/puppet/cgroups/spec/classes/cgroups_service_spec.rb | |||
@@ -9,8 +9,6 @@ describe 'cgroups::service', :type => :class do | |||
9 | } | 9 | } |
10 | end | 10 | end |
11 | 11 | ||
12 | %w(cgroup-lite cgconfigparser cgrulesengd).each do |cg_service| | 12 | it { is_expected.to contain_service('cgconfig') } |
13 | it { is_expected.to contain_service(cg_service) } | ||
14 | end | ||
15 | end | 13 | end |
16 | end | 14 | end |