Skip to content

Commit f5e6c9b

Browse files
author
Anu Sudarsan
committed
Add --nodeps option to Presto RPM operations
This commit adds a --nodeps optional flag to server uninstall. The functionality is similar to --nodeps flag to rpm -e. The --nodeps flag feature already existed for server install and upgrade, but the help text was missing. So added those as well. Testing: manual testing, make clean lint test
1 parent ed9a21b commit f5e6c9b

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

docs/presto-admin-commands.rst

+13-3
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ server install
368368
**************
369369
::
370370

371-
presto-admin server install <local_path>
371+
presto-admin server install <local_path> [--nodeps]
372372

373373
This command copies the presto-server rpm from ``local_path`` to all the nodes in the cluster, installs it, deploys the general presto configuration along with tpch connector configuration. The ``local_path`` should be accessible by ``presto-admin``.
374374
The topology used to configure the nodes are obtained from ``/etc/opt/prestoadmin/config.json``. See :ref:`presto-admin-configuration-label` on how to configure your cluster using config.json. If this file is missing, then the command prompts for user input to get the topology information.
@@ -378,6 +378,10 @@ The general configurations for Presto's coordinator and workers are taken from t
378378
The connectors directory ``/etc/opt/prestoadmin/connectors/`` should contain the configuration files for any catalogs that you would like to connect to in your Presto cluster.
379379
The ``server install`` command will configure the cluster with all the connectors in the directory. If the directory does not exist or is empty prior to ``server install``, then by default the tpch connector is configured. See `connector add`_ on how to add connector configuration files after installation.
380380

381+
This command takes an optional ``--nodeps`` flag which indicates if the rpm installed should ignore checking any package dependencies.
382+
383+
.. WARNING:: Using ``--nodeps`` can result in installing the rpm even with any missing dependencies, so you may end up with a broken rpm installation.
384+
381385
Example
382386
-------
383387
::
@@ -476,11 +480,13 @@ server uninstall
476480
****************
477481
::
478482

479-
presto-admin server uninstall
483+
presto-admin server uninstall [--nodeps]
480484

481485
This command stops the Presto server if running on the cluster and uninstalls the Presto rpm. The uninstall command removes any presto
482486
related files deployed during ``server install`` but retains the Presto logs at ``/var/log/presto``.
483487

488+
This command takes an optional ``--nodeps`` flag which indicates if the rpm uninstalled should ignore checking any package dependencies.
489+
484490
Example
485491
-------
486492
::
@@ -493,7 +499,7 @@ server upgrade
493499
**************
494500
::
495501

496-
presto-admin server upgrade path/to/new/package.rpm [local_config_dir]
502+
presto-admin server upgrade path/to/new/package.rpm [local_config_dir] [--nodeps]
497503

498504
This command upgrades the Presto RPM on all of the nodes in the cluster to the RPM at
499505
``path/to/new/package.rpm``, preserving the existing configuration on the cluster. The existing
@@ -507,6 +513,10 @@ This command can also be used to downgrade the Presto installation, if the RPM a
507513
Note that if the configuration files on the cluster differ from the presto-admin configuration
508514
files found in ``/etc/opt/prestoadmin``, the presto-admin configuration files are not updated.
509515

516+
This command takes an optional ``--nodeps`` flag which indicates if the rpm upgrade should ignore checking any package dependencies.
517+
518+
.. WARNING:: Using ``--nodeps`` can result in installing the rpm even with any missing dependencies, so you may end up with a broken rpm upgrade.
519+
510520
Example
511521
-------
512522
::

prestoadmin/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,9 @@ def show_commands(docstring, format, code=0):
558558
def run_tasks(task_list):
559559
for name, args, kwargs, arg_hosts, arg_roles, arg_excl_hosts in task_list:
560560
try:
561-
if state.env.nodeps and name.strip() != 'package.install':
561+
nodeps_tasks = ['package.install', 'server.uninstall',
562+
'server.install', 'server.upgrade']
563+
if state.env.nodeps and name.strip() not in nodeps_tasks:
562564
sys.stderr.write('Invalid argument --nodeps to task: %s\n'
563565
% name)
564566
display_command(name, 2)

prestoadmin/server.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ def install(local_path):
107107
jvm.config
108108
109109
Parameters:
110-
local_path - Absolute path to the presto rpm to be installed
110+
local_path - Absolute path to the presto rpm to be installed
111+
112+
--nodeps - (optional) Flag to indicate if server install
113+
should ignore checking Presto rpm package
114+
dependencies. Equivalent to adding --nodeps
115+
flag to rpm -i.
111116
"""
112117
package.check_if_valid_rpm(local_path)
113118
return execute(deploy_install_configure, local_path, hosts=get_host_list())
@@ -149,17 +154,27 @@ def wait_for_presto_user():
149154
def uninstall():
150155
"""
151156
Uninstall Presto after stopping the services on all nodes
157+
158+
Parameters:
159+
--nodeps - (optional) Flag to indicate if server uninstall
160+
should ignore checking Presto rpm package
161+
dependencies. Equivalent to adding --nodeps
162+
flag to rpm -e.
152163
"""
153164
stop()
154165

166+
nodeps = ''
167+
if env.nodeps:
168+
nodeps = ' --nodeps'
169+
155170
# currently we have two rpm names out so we need this retry
156171
with quiet():
157-
ret = sudo('rpm -e presto')
172+
ret = sudo('rpm -e%s presto' % (nodeps))
158173
if ret.succeeded:
159174
print('Package uninstalled successfully on: ' + env.host)
160175
return
161176

162-
ret = sudo('rpm -e presto-server-rpm')
177+
ret = sudo('rpm -e%s presto-server-rpm' % (nodeps))
163178
if ret.succeeded:
164179
print('Package uninstalled successfully on: ' + env.host)
165180

@@ -190,6 +205,11 @@ def upgrade(new_rpm_path, local_config_dir=None, overwrite=False):
190205
directory is used.
191206
:param overwrite - (optional) if set to True then existing
192207
configuration will be orerwriten.
208+
209+
:param --nodeps - (optional) Flag to indicate if server upgrade
210+
should ignore checking Presto rpm package
211+
dependencies. Equivalent to adding --nodeps
212+
flag to rpm -U.
193213
"""
194214
stop()
195215

tests/unit/test_server.py

+14
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_deploy_install_configure(self, mock_update, mock_install,
7070
@patch('prestoadmin.server.sudo')
7171
def test_uninstall_is_called(self, mock_sudo, mock_version_check):
7272
env.host = "any_host"
73+
env.nodeps = False
7374
mock_sudo.side_effect = self.mock_fail_then_succeed()
7475

7576
server.uninstall()
@@ -78,6 +79,19 @@ def test_uninstall_is_called(self, mock_sudo, mock_version_check):
7879
mock_sudo.assert_any_call('rpm -e presto')
7980
mock_sudo.assert_called_with('rpm -e presto-server-rpm')
8081

82+
@patch('prestoadmin.server.check_presto_version')
83+
@patch('prestoadmin.server.sudo')
84+
def test_uninstall_with_nodeps(self, mock_sudo, mock_version_check):
85+
env.host = 'any_host'
86+
env.nodeps = True
87+
mock_sudo.side_effect = self.mock_fail_then_succeed()
88+
89+
server.uninstall()
90+
91+
mock_version_check.assert_called_with()
92+
mock_sudo.assert_any_call('rpm -e --nodeps presto')
93+
mock_sudo.assert_called_with('rpm -e --nodeps presto-server-rpm')
94+
8195
@patch('prestoadmin.util.remote_config_util.lookup_in_config')
8296
@patch('prestoadmin.server.run')
8397
@patch('prestoadmin.server.sudo')

0 commit comments

Comments
 (0)