Skip to content

Commit

Permalink
Closes-Bug: #1558879, kernel crash dump is not working with server ma…
Browse files Browse the repository at this point in the history
…nager

Change-Id: Ib99b25e8aa132a5edf147d61a66ac16a757a87bd
  • Loading branch information
miriyalar committed Mar 18, 2016
1 parent 92801e9 commit 79bb9ac
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
26 changes: 21 additions & 5 deletions contrail/environment/modules/contrail/files/enable_kernel_core.py
@@ -1,6 +1,8 @@
import os
import re
import tempfile

import platform
import subprocess

class ExtList (list):

Expand All @@ -12,6 +14,15 @@ def findex(self, fun):
# end def findex
# end class ExtList

def setup_crashkernel_params(pdist, pdistversion):
if pdistversion == '14.04':
if os.path.exists('/etc/default/grub.d/kexec-tools.cfg'):
subprocess.call(r"sed -i 's/crashkernel=.*\([ | \"]\)/crashkernel=384M-2G:64M,2G-16G:128M,16G-:256M\1/g' /etc/default/grub.d/kexec-tools.cfg", shell=True)
if os.path.exists('/etc/default/kdump-tools'):
subprocess.call("sed -i 's/USE_KDUMP=0/USE_KDUMP=1/' /etc/default/kdump-tools", shell=True)
else:
subprocess.call(r"sed -i 's/crashkernel=.*\([ | \"]\)/crashkernel=384M-2G:64M,2G-16G:128M,16G-:256M\1/g' /etc/grub.d/10_linux", shell=True)
subprocess.call("update-grub", shell=True)

def enable_kernel_core():
'''
Expand Down Expand Up @@ -42,14 +53,19 @@ def enable_kernel_core():
with open('%s/grub' % _temp_dir_name, 'w') as f:
f.write('\n'.join(el))
f.flush()
local('mv %s/grub /etc/default/grub' % (_temp_dir_name))
local('/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg')
cmd = 'mv %s/grub /etc/default/grub' % (_temp_dir_name)
subprocess.call(cmd, shell=True)
subprocess.call('/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg', shell=True)
except LookupError:
print 'Improper grub file, kernel crash not enabled'
# end enable_kernel_core

if __name__ == "__main__":
import cgitb
cgitb.enable(format='text')

enable_kernel_core()
(pdist, pdistversion, pdistrelease) = platform.dist()
if pdist in ['fedora', 'centos', 'redhat']:
enable_kernel_core()
if pdist == 'Ubuntu':
setup_crashkernel_params(pdist, pdistversion)

31 changes: 16 additions & 15 deletions contrail/environment/modules/contrail/manifests/common.pp
Expand Up @@ -96,6 +96,22 @@
}
->
package { 'libssl0.9.8' : ensure => present,}
->
# Make sure our scripts directory is present
file { ['/var/log/mysql', '/var/crashes', '/etc/contrail', '/etc/contrail/contrail_setup_utils'] :
ensure => 'directory',
}
->
# Enable kernel core.
file { '/etc/contrail/contrail_setup_utils/enable_kernel_core.py':
ensure => present,
mode => '0755',
owner => root,
group => root,
source => "puppet:///modules/${module_name}/enable_kernel_core.py"
}
->
class {'::contrail::enable_kernel_core':}

# Disable SELINUX on boot, if not already disabled.
if ($::operatingsystem == 'Centos' or $::operatingsystem == 'Fedora') {
Expand Down Expand Up @@ -148,19 +164,4 @@
value => "35357,35358,33306,${::ipv4_reserved_ports}"
}

# Make sure our scripts directory is present
file { ['/var/log/mysql', '/var/crashes', '/etc/contrail', '/etc/contrail/contrail_setup_utils'] :
ensure => 'directory',
}

# Enable kernel core.
file { '/etc/contrail/contrail_setup_utils/enable_kernel_core.py':
ensure => present,
mode => '0755',
owner => root,
group => root,
source => "puppet:///modules/${module_name}/enable_kernel_core.py"
}
->
class {'::contrail::enable_kernel_core':}
}
Expand Up @@ -3,6 +3,9 @@
) {
# enable kernel core , below python code has bug, for now ignore by executing echo regardless and thus returning true for cmd.
# need to revisit afterwards.

package { 'linux-crashdump' : ensure => present,}
->
exec { 'enable-kernel-core' :
command => 'python /etc/contrail/contrail_setup_utils/enable_kernel_core.py; echo enable-kernel-core >> /etc/contrail/contrail_common_exec.out',
require => File['/etc/contrail/contrail_setup_utils/enable_kernel_core.py' ],
Expand Down

0 comments on commit 79bb9ac

Please sign in to comment.