From d0b1c1fd6ca492ff8cad0a319b05af34108a2d68 Mon Sep 17 00:00:00 2001 From: Grahame Bowland Date: Fri, 5 Sep 2014 09:36:31 +0800 Subject: [PATCH 1/4] replace direct calls to init script with calls to /sbin/service --- starcluster/node.py | 6 +++--- starcluster/plugins/condor.py | 2 +- starcluster/plugins/hadoop.py | 10 +++++----- starcluster/plugins/mysql.py | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/starcluster/node.py b/starcluster/node.py index 39d70a207..0b488ce0b 100644 --- a/starcluster/node.py +++ b/starcluster/node.py @@ -702,7 +702,7 @@ def stop_exporting_fs_to_nodes(self, nodes, paths=None): def start_nfs_server(self): log.info("Starting NFS server on %s" % self.alias) - self.ssh.execute('/etc/init.d/portmap start', ignore_exit_status=True) + self.ssh.execute('service portmap start', ignore_exit_status=True) self.ssh.execute('mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs/', ignore_exit_status=True) EXPORTSD = '/etc/exports.d' @@ -716,7 +716,7 @@ def start_nfs_server(self): self.ssh.execute("mkdir -p %s" % DUMMY_EXPORT_DIR) with self.ssh.remote_file(DUMMY_EXPORT_FILE, 'w') as dummyf: dummyf.write(DUMMY_EXPORT_LINE) - self.ssh.execute('/etc/init.d/nfs start') + self.ssh.execute('service nfs start') self.ssh.execute('rm -f %s' % DUMMY_EXPORT_FILE) self.ssh.execute('rm -rf %s' % DUMMY_EXPORT_DIR) self.ssh.execute('exportfs -fra') @@ -728,7 +728,7 @@ def mount_nfs_shares(self, server_node, remote_paths): server_node - remote server node that is sharing the remote_paths remote_paths - list of remote paths to mount from server_node """ - self.ssh.execute('/etc/init.d/portmap start') + self.ssh.execute('service portmap start') # TODO: move this fix for xterm somewhere else self.ssh.execute('mount -t devpts none /dev/pts', ignore_exit_status=True) diff --git a/starcluster/plugins/condor.py b/starcluster/plugins/condor.py index f21096da6..eeda5bdbe 100644 --- a/starcluster/plugins/condor.py +++ b/starcluster/plugins/condor.py @@ -40,7 +40,7 @@ def _add_condor_node(self, node): config_vals = ['$(condor_config_val %s)' % var for var in config_vars] node.ssh.execute('mkdir -p %s' % ' '.join(config_vals)) node.ssh.execute('chown -R condor:condor %s' % ' '.join(config_vals)) - node.ssh.execute('/etc/init.d/condor start') + node.ssh.execute('service condor start') def _setup_condor(self, master=None, nodes=None): log.info("Setting up Condor grid") diff --git a/starcluster/plugins/hadoop.py b/starcluster/plugins/hadoop.py index 98862b1f8..a94d65ea0 100644 --- a/starcluster/plugins/hadoop.py +++ b/starcluster/plugins/hadoop.py @@ -279,23 +279,23 @@ def _setup_hadoop_dir(self, node, path, user, group, permission="775"): node.ssh.execute("chmod -R %s %s" % (permission, path)) def _start_datanode(self, node): - node.ssh.execute('/etc/init.d/hadoop-0.20-datanode restart') + node.ssh.execute('service hadoop-0.20-datanode restart') def _start_tasktracker(self, node): - node.ssh.execute('/etc/init.d/hadoop-0.20-tasktracker restart') + node.ssh.execute('service hadoop-0.20-tasktracker restart') def _start_hadoop(self, master, nodes): log.info("Starting namenode...") - master.ssh.execute('/etc/init.d/hadoop-0.20-namenode restart') + master.ssh.execute('service hadoop-0.20-namenode restart') log.info("Starting secondary namenode...") - master.ssh.execute('/etc/init.d/hadoop-0.20-secondarynamenode restart') + master.ssh.execute('service hadoop-0.20-secondarynamenode restart') log.info("Starting datanode on all nodes...") for node in nodes: self.pool.simple_job(self._start_datanode, (node,), jobid=node.alias) self.pool.wait() log.info("Starting jobtracker...") - master.ssh.execute('/etc/init.d/hadoop-0.20-jobtracker restart') + master.ssh.execute('service hadoop-0.20-jobtracker restart') log.info("Starting tasktracker on all nodes...") for node in nodes: self.pool.simple_job(self._start_tasktracker, (node,), diff --git a/starcluster/plugins/mysql.py b/starcluster/plugins/mysql.py index 1c0ac6ca6..2dbfe9f80 100644 --- a/starcluster/plugins/mysql.py +++ b/starcluster/plugins/mysql.py @@ -191,10 +191,10 @@ class MysqlCluster(DefaultClusterSetup): 2. chown -R mysql:mysql /var/lib/mysql-cluster/ 3. generate ndb-mgmd for master 4. generate my.cnf for data nodes - 5. /etc/init.d/mysql-ndb-mgm restart on master + 5. service mysql-ndb-mgm restart on master 6. pkill -9 mysql on data nodes - 7. /etc/init.d/mysql start on data nodes - 8. /etc/init.d/mysql-ndb restart on data nodes + 7. service mysql start on data nodes + 8. service mysql-ndb restart on data nodes Correction to above, do this: 1. define plugin section in config named mysql @@ -279,19 +279,19 @@ def run(self, nodes, master, user, user_shell, volumes): self.pool.wait(len(nodes)) # Restart mysql-ndb-mgm on master log.info('Restarting mysql-ndb-mgm on master node...') - mconn.execute('/etc/init.d/mysql-ndb-mgm restart') + mconn.execute('service mysql-ndb-mgm restart') # Start mysqld-ndb on data nodes log.info('Restarting mysql-ndb on all data nodes...') for node in self.data_nodes: self.pool.simple_job(node.ssh.execute, - ('/etc/init.d/mysql-ndb restart'), + ('service mysql-ndb restart'), jobid=node.alias) self.pool.wait(len(self.data_nodes)) # Start mysql on query nodes log.info('Starting mysql on all query nodes') for node in self.query_nodes: self.pool.simple_job(node.ssh.execute, - ('/etc/init.d/mysql restart'), + ('service mysql restart'), dict(ignore_exit_status=True), jobid=node.alias) self.pool.wait(len(self.query_nodes)) From 92b32e39c4a8fbfbe9ab63dbf3289adb7f57e91a Mon Sep 17 00:00:00 2001 From: Grahame Bowland Date: Fri, 5 Sep 2014 10:45:10 +0800 Subject: [PATCH 2/4] detect the name of 'rpcbind' service, use correct service name when starting NFS --- starcluster/node.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/starcluster/node.py b/starcluster/node.py index 0b488ce0b..6ab7884a6 100644 --- a/starcluster/node.py +++ b/starcluster/node.py @@ -91,6 +91,7 @@ def __init__(self, instance, key_location, alias=None, user='root'): self._groups = None self._ssh = None self._num_procs = None + self._rpcbind_service_name = None self._memory = None self._user_data = None @@ -229,6 +230,22 @@ def num_processors(self): 'cat /proc/cpuinfo | grep processor | wc -l')[0]) return self._num_procs + @property + def rpcbind_service_name(self): + """ + Determine whether the system uses 'rpcbind' to name the RPC + service, or whether it uses the legacy 'portmap' name. + """ + if not self._rpcbind_service_name: + try: + self.ssh.execute( + 'test -e /etc/init.d/rpcbind', + raise_on_failure=True) + self._rpcbind_service_name = 'rpcbind' + except exception.SSHError: + self._rpcbind_service_name = 'portmap' + return self._rpcbind_service_name + @property def memory(self): if not self._memory: @@ -702,7 +719,7 @@ def stop_exporting_fs_to_nodes(self, nodes, paths=None): def start_nfs_server(self): log.info("Starting NFS server on %s" % self.alias) - self.ssh.execute('service portmap start', ignore_exit_status=True) + self.ssh.execute('service %s start' % self.rpcbind_service_name, ignore_exit_status=True) self.ssh.execute('mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs/', ignore_exit_status=True) EXPORTSD = '/etc/exports.d' @@ -728,7 +745,8 @@ def mount_nfs_shares(self, server_node, remote_paths): server_node - remote server node that is sharing the remote_paths remote_paths - list of remote paths to mount from server_node """ - self.ssh.execute('service portmap start') + self.ssh.execute('service %s start' % self.rpcbind_service_name, + ignore_exit_status=True) # TODO: move this fix for xterm somewhere else self.ssh.execute('mount -t devpts none /dev/pts', ignore_exit_status=True) From 600a5f9f6875895a453d4c53943f7aa248f3a7b8 Mon Sep 17 00:00:00 2001 From: Grahame Bowland Date: Fri, 5 Sep 2014 14:31:24 +0800 Subject: [PATCH 3/4] fix PEP8 lint issues --- starcluster/node.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/starcluster/node.py b/starcluster/node.py index 6ab7884a6..6b23119dd 100644 --- a/starcluster/node.py +++ b/starcluster/node.py @@ -719,7 +719,9 @@ def stop_exporting_fs_to_nodes(self, nodes, paths=None): def start_nfs_server(self): log.info("Starting NFS server on %s" % self.alias) - self.ssh.execute('service %s start' % self.rpcbind_service_name, ignore_exit_status=True) + self.ssh.execute( + 'service %s start' % self.rpcbind_service_name, + ignore_exit_status=True) self.ssh.execute('mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs/', ignore_exit_status=True) EXPORTSD = '/etc/exports.d' @@ -745,8 +747,9 @@ def mount_nfs_shares(self, server_node, remote_paths): server_node - remote server node that is sharing the remote_paths remote_paths - list of remote paths to mount from server_node """ - self.ssh.execute('service %s start' % self.rpcbind_service_name, - ignore_exit_status=True) + self.ssh.execute( + 'service %s start' % self.rpcbind_service_name, + ignore_exit_status=True) # TODO: move this fix for xterm somewhere else self.ssh.execute('mount -t devpts none /dev/pts', ignore_exit_status=True) From 7ebffb42321d8f9f7eb4e4259648f109bee269be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 1 Sep 2015 19:04:31 +0200 Subject: [PATCH 4/4] working trusty support --- starcluster/node.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/starcluster/node.py b/starcluster/node.py index 6b23119dd..7a0f872ec 100644 --- a/starcluster/node.py +++ b/starcluster/node.py @@ -91,6 +91,7 @@ def __init__(self, instance, key_location, alias=None, user='root'): self._groups = None self._ssh = None self._num_procs = None + self._nfs_service_name = None self._rpcbind_service_name = None self._memory = None self._user_data = None @@ -230,6 +231,22 @@ def num_processors(self): 'cat /proc/cpuinfo | grep processor | wc -l')[0]) return self._num_procs + @property + def nfs_service_name(self): + """ + Determine whether the system uses 'nfs-kernel-server' to name + the NFS service, or whether it uses the legacy 'nfs' name. + """ + if not self._nfs_service_name: + try: + self.ssh.execute( + 'test -e /etc/init.d/nfs-kernel-server', + raise_on_failure=True) + self._nfs_service_name = 'nfs-kernel-server' + except exception.SSHError: + self._nfs_service_name = 'nfs' + return self._nfs_service_name + @property def rpcbind_service_name(self): """ @@ -719,9 +736,7 @@ def stop_exporting_fs_to_nodes(self, nodes, paths=None): def start_nfs_server(self): log.info("Starting NFS server on %s" % self.alias) - self.ssh.execute( - 'service %s start' % self.rpcbind_service_name, - ignore_exit_status=True) + self.ssh.execute('service %s restart' % self.rpcbind_service_name) self.ssh.execute('mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs/', ignore_exit_status=True) EXPORTSD = '/etc/exports.d' @@ -735,7 +750,7 @@ def start_nfs_server(self): self.ssh.execute("mkdir -p %s" % DUMMY_EXPORT_DIR) with self.ssh.remote_file(DUMMY_EXPORT_FILE, 'w') as dummyf: dummyf.write(DUMMY_EXPORT_LINE) - self.ssh.execute('service nfs start') + self.ssh.execute('service %s restart' % self.nfs_service_name) self.ssh.execute('rm -f %s' % DUMMY_EXPORT_FILE) self.ssh.execute('rm -rf %s' % DUMMY_EXPORT_DIR) self.ssh.execute('exportfs -fra') @@ -747,9 +762,7 @@ def mount_nfs_shares(self, server_node, remote_paths): server_node - remote server node that is sharing the remote_paths remote_paths - list of remote paths to mount from server_node """ - self.ssh.execute( - 'service %s start' % self.rpcbind_service_name, - ignore_exit_status=True) + self.ssh.execute('service %s restart' % self.rpcbind_service_name) # TODO: move this fix for xterm somewhere else self.ssh.execute('mount -t devpts none /dev/pts', ignore_exit_status=True)