Ori.livneh has submitted this change and it was merged.
Change subject: ensure tmpfile is accessible to dsh subprocess
......................................................................
ensure tmpfile is accessible to dsh subprocess
Specify delete=False in invocation of NamedTemporaryFile constructor to ensure
that the temporary file it creates exists on disk and is accessible to other
processes. Wrap the dsh invocations that depend on it in a try / finally. In
the finally block, ensure the file is cleaned up.
Change-Id: I3ea77bddd50601c06a476f3392f776c467fc2335
---
M files/scap/scappy
1 file changed, 10 insertions(+), 8 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/files/scap/scappy b/files/scap/scappy
index 55de8fd..02c3395 100755
--- a/files/scap/scappy
+++ b/files/scap/scappy
@@ -157,14 +157,16 @@
# Randomize the order of target machines
hosts = [ln for ln in f if not ln.startswith('#')]
random.shuffle(hosts)
- with tempfile.NamedTemporaryFile(prefix='scap') as tmp:
- tmp.write(''.join(hosts))
- log.debug('copying code to apaches')
- dsh('/usr/local/bin/scap-1 "%s"' % rsync_servers,
- tmp.name, env)
-
- log.debug('rebuilding CDB files from /upstream')
- dsh('/usr/local/bin/scap-rebuild-cdbs', tmp.name, env)
+ with tempfile.NamedTemporaryFile(delete=False) as tmp:
+ try:
+ tmp.write(''.join(hosts))
+ log.debug('copying code to apaches')
+ dsh('/usr/local/bin/scap-1 "%s"' % rsync_servers,
+ tmp.name, env)
+ log.debug('rebuilding CDB files from /upstream')
+ dsh('/usr/local/bin/scap-rebuild-cdbs', tmp.name, env)
+ finally:
+ os.remove(tmp.name)
# Builds wikiversions.cdb and syncs it to the apaches with the dat
# file. This is done after all else so that deploying new MW versions
--
To view, visit https://gerrit.wikimedia.org/r/111375
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3ea77bddd50601c06a476f3392f776c467fc2335
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits