Hashar has uploaded a new change for review.
https://gerrit.wikimedia.org/r/270902
Change subject: beta: update db script strip output on error
......................................................................
beta: update db script strip output on error
The wmf-beta-update-databases fails to output stdout/stderr which is
stored in a temporary file. The root cause is we read() before rewinding
the file pointer to the beginning (with seek(0)).
Replace the temporary file with a pipe.
Redirect STDERR to STDOUT so we get them properly aligned.
Bug: T110407
Change-Id: Ib083b5d6134ac1bf43ee79d0f25aa145e81f29d0
---
M modules/beta/files/wmf-beta-update-databases.py
1 file changed, 7 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/02/270902/1
diff --git a/modules/beta/files/wmf-beta-update-databases.py
b/modules/beta/files/wmf-beta-update-databases.py
index 8795365..44997c8 100755
--- a/modules/beta/files/wmf-beta-update-databases.py
+++ b/modules/beta/files/wmf-beta-update-databases.py
@@ -27,12 +27,10 @@
"""
wait for command in procs array to execute, dump their output
"""
- for p, f, cmd in procs:
- if p.wait() > 0:
- raise Exception("command: ", cmd, "output: ", f.read())
- f.seek(0)
- print f.read().strip()
- f.close()
+ for p, cmd in procs:
+ (out, stderr_unused) = p.communicate()
+ if p.returncode:
+ raise Exception("command: ", cmd, "output:", out)
def run_updates(staging, cores):
@@ -43,10 +41,10 @@
with open(staging, "r") as dblist:
for db in dblist:
db = db.strip()
- f = os.tmpfile()
cmd = "/usr/local/bin/mwscript update.php --wiki=%s --quick" % db
- p = subprocess.Popen(cmd, stdout=f, stderr=f, shell=True)
- procs.append((p, f, cmd))
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, shell=True)
+ procs.append((p, cmd))
if (len(procs) >= cores):
do_wait(procs)
procs = []
--
To view, visit https://gerrit.wikimedia.org/r/270902
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib083b5d6134ac1bf43ee79d0f25aa145e81f29d0
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Hashar <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits