Muehlenhoff has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/373865 )
Change subject: Add support for querying reverse dependencies
......................................................................
Add support for querying reverse dependencies
Executes debdeploy-revdeps on the clients.
Change-Id: I2865a2c447c5b44563d1ee7cff65bc10275f4c51
---
M server/debdeploy
1 file changed, 62 insertions(+), 40 deletions(-)
Approvals:
Muehlenhoff: Looks good to me, approved
jenkins-bot: Verified
diff --git a/server/debdeploy b/server/debdeploy
index 63c77ae..701d5b9 100755
--- a/server/debdeploy
+++ b/server/debdeploy
@@ -7,23 +7,22 @@
import argparse
import code
+import cumin
+import datetime
import json
import logging
import os
import pkgutil
+import pydoc
import signal
import sys
-import datetime
+import textwrap
from ClusterShell.NodeSet import NodeSet
-import cumin
-
from cumin import query, transport, transports
from debdeploy_conf import *
-import pydoc
from debdeploy_updatespec import *
-
if os.geteuid() != 0:
print "debdeploy needs to be run as root"
@@ -168,7 +167,8 @@
msg = str(output)
if msg.startswith("OK "):
if str(msg[3:]) == '"No service needs a restart"':
- no_restarts_needed = nodeset
+ print "No restarts were needed for", len(no_restarts_needed),
"host(s):"
+ print nodeset
else:
restarts = json.loads(msg[3:])
if restarts:
@@ -187,45 +187,70 @@
print " ", program
print " " + str(restarts_per_lib[lib][program]) + " (" +
str(len(restarts_per_lib[lib][program])) + " hosts)"
- if no_restarts_needed:
- print
- print "No restarts were needed for", len(no_restarts_needed),
"host(s)."
+ show_unreachable_hosts(worker)
+
+
+def detect_rev_deps(pkgnames, servergroup):
+ '''
+ Query for necessary restarts after a library or interpreter upgrade
+
+ pkgnames : A list of package names for which reverse dependencies are
displayed,
+ e.g. libssl1.1 (list of strings)
+ servergroup : The name of the server group for which process restarts
should be queried (string)
+ '''
+
+ cmd = '/usr/bin/debdeploy-revdeps --json ' + ' '.join(pkgnames)
+
+ worker = run_cumin(cmd)
+
+ status_print = textwrap.TextWrapper(initial_indent=' ')
+ for nodeset, output in worker.get_results():
+ msg = str(output)
+ if msg.startswith("OK "):
+ deps = json.loads(msg[3:])
+ if deps:
+ print nodeset
+ for service in deps:
+ print status_print.fill(service)
+ else:
+ print nodeset
+ print status_print.fill("No reverse dependencies installed")
show_unreachable_hosts(worker)
-def main():
- p = argparse.ArgumentParser(usage="""debdeploy-master [options] command
<cmd-option> \n
- The following commands are supported: \n\n
- deploy Install a software update, requires --update
and --servers \n
- query_restart Query for necessary restarts after a library
or interpreter \n
- upgrade \n
- rollback Rollback a software deployment""")
- p.add_argument("-u", "--update", action="store", type=str,
dest="updatefile",
- help="A YAML file containing the update specification
(which source package to \
- update and the respective fixed versions")
- p.add_argument("-s", "--servers", action="store", type=str,
dest="serverlist",
- help="The group of servers on which the update should be
applied")
+def main():
+ p = argparse.ArgumentParser()
+
p.add_argument("--verbose", action="store_true", dest="verbose",
help="Enable verbose output, e.g. show full apt output in
status-deploy and \
status-rollback")
- p.add_argument("command")
- p.add_argument("command_option", nargs="?", default="unset")
+ subp = p.add_subparsers(title='Command', description='Valid commands',
dest='command')
+ parser_deps = subp.add_parser('query_deps', help='Query for necessary
restarts after a library or interpreter upgrade')
+ parser_deps.add_argument('--packages', action='store', nargs='+',
+ help="Packages to query reverse dependencies",
required=True)
+ parser_deps.add_argument("-s", "--servers", action="store", type=str,
dest="serverlist",
+ help="The group of servers for which reverse
dependencies should be queried",
+ required=True)
+
+ parser_deploy = subp.add_parser('deploy', help='Install a software update')
+ parser_deploy.add_argument("-s", "--servers", action="store", type=str,
dest="serverlist",
+ help="The group of servers on which the update
should be applied",
+ required=True)
+ parser_deploy.add_argument("-u", "--update", action="store", type=str,
dest="updatefile",
+ help="A YAML file containing the update
specification (which source package to \
+ update and the respective fixed versions",
required=True)
+
+ parser_restart = subp.add_parser('query_restart', help='Query necesssary
service restarts after library update')
+ parser_restart.add_argument("-s", "--servers", action="store", type=str,
dest="serverlist",
+ help="The group of servers for which necessary
service restarts should be detected",
+ required=True)
+ parser_restart.add_argument("-u", "--update", action="store", type=str,
dest="updatefile",
+ help="A YAML file containing the update
specification (which source package to \
+ update and the respective fixed versions",
required=True)
opt = p.parse_args()
-
- if opt.command in ("deploy", "rollback", "restart", "query_restart"):
- if not opt.serverlist:
- p.error("You need to provide a server list (-s)")
-
- if opt.command in ("deploy", "rollback", "query_restart"):
- if not opt.updatefile:
- p.error("You need to provide an update file (-u)")
-
- if opt.command in ("restart"):
- if not opt.program:
- p.error("You need to provide a program to restart (-p)")
if opt.command == "deploy":
update = DebDeployUpdateSpec(opt.updatefile, conf.supported_distros)
@@ -236,11 +261,8 @@
update = DebDeployUpdateSpec(opt.updatefile, conf.supported_distros)
detect_restarts(update.libraries, opt.serverlist)
- elif opt.command == "status-rollback":
- display_status(rollback_mode=True)
-
- elif opt.command == "rollback":
- rollback(opt.serverlist, opt.updatefile)
+ elif opt.command == "query_deps":
+ detect_rev_deps(opt.packages, opt.serverlist)
if __name__ == '__main__':
--
To view, visit https://gerrit.wikimedia.org/r/373865
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2865a2c447c5b44563d1ee7cff65bc10275f4c51
Gerrit-PatchSet: 3
Gerrit-Project: operations/debs/debdeploy
Gerrit-Branch: master
Gerrit-Owner: Muehlenhoff <[email protected]>
Gerrit-Reviewer: Muehlenhoff <[email protected]>
Gerrit-Reviewer: Volans <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits