提交 29f17dd8 编写于 作者: C C.J. Jameson 提交者: Management and Monitoring Team

Remove gpkill related code

Signed-off-by: NMarbin Tan <mtan@pivotal.io>
上级 77c5aba7
......@@ -72,10 +72,6 @@ class GpDebugMain(YamlMain):
help: Hosts file
type: string
dest: hostsfile
-o:
help: Output file with details and gpkill commands
type: string
dest: outputfile
--orphans:
help: Search cluster for orphan processes
action: store_const
......@@ -308,28 +304,6 @@ class GpDebugMain(YamlMain):
tabLog.outputTable()
self.logger.info("--------------------------------------------")
def generate_output_file(self):
""
if self.options.outputfile is None:
return
self.logger.info('writing gpkill script to %s' % self.options.outputfile)
with open(self.options.outputfile, 'w') as f:
for host, lines in self.results.items():
prev = None
for line in lines:
host2, era, sessid, pid, detail = line.split('|')
assert host == host2
if era != prev:
f.write('# era %s\n' % era)
prev = era
f.write('# sessid %s\n' % sessid)
f.write('# %s\n' % detail)
f.write('gpssh -h %s gpkill %s\n\n' % (host, pid))
#
# Scenario: Check Host For Orphans (segment hosts, via search for orphans)
#
......
#!/usr/bin/env python
from gppylib.mainUtils import simple_main
from gppylib.programs.kill import KillProgram
if __name__ == '__main__':
simple_main(KillProgram.create_parser, KillProgram)
......@@ -275,7 +275,7 @@ class PgCtlStartArgs(CmdArgs):
"""
CmdArgs.__init__(self, [
"env", # variables examined by gpkill/gpdebug/etc
"env", # variables examined by gpdebug/etc
"GPSESSID=0000000000", # <- overwritten with gp_session_id to help identify orphans
"GPERA=%s" % str(era), # <- master era used to help identify orphans
"$GPHOME/bin/pg_ctl",
......
# Line too long - pylint: disable=C0301
# Copyright (c) Greenplum Inc 2011. All Rights Reserved.
from gppylib import gplog
from gppylib.commands import gp
from optparse import OptionGroup
from gppylib.gpparseopts import OptParser, OptChecker
from gppylib.mainUtils import addStandardLoggingAndHelpOptions, ProgramArgumentValidationException
from gppylib.commands.unix import kill_sequence, check_pid
from gppylib.operations.package import dereference_symlink
from psutil import Process, NoSuchProcess
logger = gplog.get_default_logger()
class KillError(Exception): pass
class KillProgram:
def __init__(self, options, args):
self.check = options.check
self.pid_list = args
@staticmethod
def create_parser():
"""Create the command line parser object for gpkill"""
help = []
parser = OptParser(option_class=OptChecker,
description='Check or Terminate a Greenplum Database process.',
version='%prog version $Revision: #1 $')
parser.setHelp(help)
addStandardLoggingAndHelpOptions(parser, True)
parser.remove_option('-l')
parser.remove_option('-a')
addTo = OptionGroup(parser, 'Check Options')
parser.add_option_group(addTo)
addTo.add_option('--check', metavar='pid', help='Only returns status 0 if pid may be killed without gpkill, status 1 otherwise.', action='store_true')
return parser
@staticmethod
def create_program(options, args):
return KillProgram(options, args)
def cleanup(self): pass
def run(self):
self.validate_arguments()
if self.check:
for pid in self.pid_list:
self.validate_attempt(pid)
else:
for pid in self.pid_list:
self.terminate_process(pid)
return 0
def validate_arguments(self):
if len(self.pid_list) < 1:
raise KillError('No pid specified')
int_pid_list = []
try:
for x in self.pid_list:
int_pid_list.append(int(x))
except ValueError, e:
raise KillError('Invalid pid specified (%s)' % x)
self.pid_list = int_pid_list
def validate_attempt(self, pid):
"""
Checks if we can kill the process
"""
command = self.examine_process(pid)
critical_process_prefix = ['postgres', gp.get_gphome(), dereference_symlink(gp.get_gphome())]
for prefix in critical_process_prefix:
if command.startswith(prefix):
raise KillError('process %s may not be killed' % pid)
if not command.startswith('python ' + gp.get_gphome()):
raise KillError('process %s ignored by gpkill as it is not a greenplum process' % pid)
def examine_process(self, pid):
logger.info('Examining process: pid(%s)' % pid)
try:
proc = Process(pid=pid)
except NoSuchProcess, e:
raise KillError('Process with pid(%s) does not exist' % pid)
command = ' '.join(proc.cmdline())
logger.info('process %s is %s' % (pid, command.strip()))
return command.strip()
def terminate_process(self, pid):
self.validate_attempt(pid)
logger.warning('Confirm [N/y]:')
confirmation = raw_input().strip().lower()
if confirmation not in ['y', 'ye', 'yes']:
raise KillError('operation aborted')
kill_sequence(pid)
if check_pid(pid):
raise KillError('Failed to kill process %s' % pid)
COMMAND NAME: gpkill
Checks or terminates a Greenplum Database process.
Users other than the superuser can only use gpkill
to terminate their own processes.
*****************************************************
SYNOPSIS
*****************************************************
gpkill [options] pid
gpkill --version
gpkill -? | -h | --help
*****************************************************
DESCRIPTION
*****************************************************
This utility checks or terminates a Greenplum process.
If the process is a critical Greenplum Database process
or a system process that is not part of Greenplum, gpkill
does not terminate it.
After gpkill verifies that the specified process can be
terminated safely, it prompts for confirmation. Prior to
terminating a process, gpkill attempts to capture
troubleshooting information, if the user has appropriate
operating system priviliges.
* The troubleshooting information is captured, even if
the user does not confirm killing the process.
* Failure to capture troubleshooting information does not
stop gpkill from proceeding.
*****************************************************
OPTIONS
*****************************************************
pid
The process ID to check or terminate.
--check
Checks the specified process ID to verify that it is a
Greenplum process and can safely be killed, but does not
erminate it.
-v
Displays verbose debugging information.
-q
Enables quiet mode. Informational messages are suppressed.
NOTE: Choosing both the -v and -q options sends the verbose
debugging information to the system log, but does not display
informational messages on stdout.
-? | -h | --help (help)
Displays the online help.
*****************************************************
EXAMPLES
*****************************************************
Kill process 27893
gpkill 27893
Check process 27893 to see if it can be killed. Send
debugging information to the system log, but do not
display informational messages.
gpkill -q -v --check 27893
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册