def _setup_docker( self ): # The docker and dockerbox init jobs depend on /mnt/persistent which is set up by the # mesosbox job. Adding a dependency of the docker job on mesosbox should satsify that # dependency. super( ToilBoxSupport, self )._setup_docker( ) with remote_sudo_popen( 'patch -d /lib/systemd/system' ) as patch: patch.write( self._docker_patch_heredoc( ) ) sudo ( "systemctl daemon-reload")
def _setup_docker( self ): super( ToilBoxSupport, self )._setup_docker( ) # The docker and dockerbox init jobs depend on /mnt/persistent which is set up by the # mesosbox job. Adding a dependency of the docker job on mesosbox should satsify that # dependency. with remote_sudo_popen( 'patch -d /etc/init' ) as patch: patch.write( heredoc( """ --- docker.conf.orig 2015-12-18 23:28:48.693072560 +0000 +++ docker.conf 2015-12-18 23:40:30.553072560 +0000 @@ -1,6 +1,6 @@ description "Docker daemon" -start on (local-filesystems and net-device-up IFACE!=lo) +start on (local-filesystems and net-device-up IFACE!=lo and started mesosbox) stop on runlevel [!2345] limit nofile 524288 1048576 limit nproc 524288 1048576""" ) )
def __patch_asynchat(self): """ This bites us in pyftpdlib during S3AM unit tests: http://jenkins.cgcloud.info/job/s3am/13/testReport/junit/src.s3am.test.s3am_tests/CoreTests/test_copy/ The patch is from https://hg.python.org/cpython/rev/d422062d7d36 http://bugs.python.org/issue16133 Fixed in 2.7.9: https://hg.python.org/cpython/raw-file/v2.7.9/Misc/NEWS """ if self._remote_python_version() < (2, 7, 9): with remote_sudo_popen('patch -d /usr/lib/python2.7 -p2') as patch: patch.write( heredoc(''' diff --git a/Lib/asynchat.py b/Lib/asynchat.py --- a/Lib/asynchat.py +++ b/Lib/asynchat.py @@ -46,12 +46,17 @@ method) up to the terminator, and then c you - by calling your self.found_terminator() method. """ +import asyncore +import errno import socket -import asyncore from collections import deque from sys import py3kwarning from warnings import filterwarnings, catch_warnings +_BLOCKING_IO_ERRORS = (errno.EAGAIN, errno.EALREADY, errno.EINPROGRESS, + errno.EWOULDBLOCK) + + class async_chat (asyncore.dispatcher): """This is an abstract class. You must derive from this class, and add the two methods collect_incoming_data() and found_terminator()""" @@ -109,6 +114,8 @@ class async_chat (asyncore.dispatcher): try: data = self.recv (self.ac_in_buffer_size) except socket.error, why: + if why.args[0] in _BLOCKING_IO_ERRORS: + return self.handle_error() return'''))
def __patch_asynchat( self ): """ This bites us in pyftpdlib during S3AM unit tests: http://jenkins.cgcloud.info/job/s3am/13/testReport/junit/src.s3am.test.s3am_tests/CoreTests/test_copy/ The patch is from https://hg.python.org/cpython/rev/d422062d7d36 http://bugs.python.org/issue16133 Fixed in 2.7.9: https://hg.python.org/cpython/raw-file/v2.7.9/Misc/NEWS """ if self._remote_python_version() < (2,7,9): with remote_sudo_popen( 'patch -d /usr/lib/python2.7 -p2' ) as patch: patch.write( heredoc( ''' diff --git a/Lib/asynchat.py b/Lib/asynchat.py --- a/Lib/asynchat.py +++ b/Lib/asynchat.py @@ -46,12 +46,17 @@ method) up to the terminator, and then c you - by calling your self.found_terminator() method. """ +import asyncore +import errno import socket -import asyncore from collections import deque from sys import py3kwarning from warnings import filterwarnings, catch_warnings +_BLOCKING_IO_ERRORS = (errno.EAGAIN, errno.EALREADY, errno.EINPROGRESS, + errno.EWOULDBLOCK) + + class async_chat (asyncore.dispatcher): """This is an abstract class. You must derive from this class, and add the two methods collect_incoming_data() and found_terminator()""" @@ -109,6 +114,8 @@ class async_chat (asyncore.dispatcher): try: data = self.recv (self.ac_in_buffer_size) except socket.error, why: + if why.args[0] in _BLOCKING_IO_ERRORS: + return self.handle_error() return''' ) )
def _setup_docker(self): super(ToilBox, self)._setup_docker() # The docker and dockerbox init jobs depend on /mnt/persistent which is set up by the # mesosbox job. Adding a dependency of the docker job on mesosbox should satsify that # dependency. with remote_sudo_popen('patch -d /etc/init') as patch: patch.write( heredoc(""" --- docker.conf.orig 2015-12-18 23:28:48.693072560 +0000 +++ docker.conf 2015-12-18 23:40:30.553072560 +0000 @@ -1,6 +1,6 @@ description "Docker daemon" -start on (local-filesystems and net-device-up IFACE!=lo) +start on (local-filesystems and net-device-up IFACE!=lo and started mesosbox) stop on runlevel [!2345] limit nofile 524288 1048576 limit nproc 524288 1048576"""))
def __patch_distutils(self): """ https://hg.python.org/cpython/rev/cf70f030a744/ https://bitbucket.org/pypa/setuptools/issues/248/exit-code-is-zero-when-upload-fails Fixed in 2.7.8: https://hg.python.org/cpython/raw-file/v2.7.8/Misc/NEWS """ if self._remote_python_version() < (2, 7, 8): with remote_sudo_popen("patch -d /usr/lib/python2.7 -p2") as patch: patch.write( heredoc( """ --- a/Lib/distutils/command/upload.py +++ b/Lib/distutils/command/upload.py @@ -10,7 +10,7 @@ import urlparse import cStringIO as StringIO from hashlib import md5 -from distutils.errors import DistutilsOptionError +from distutils.errors import DistutilsError, DistutilsOptionError from distutils.core import PyPIRCCommand from distutils.spawn import spawn from distutils import log @@ -181,7 +181,7 @@ class upload(PyPIRCCommand): self.announce(msg, log.INFO) except socket.error, e: self.announce(str(e), log.ERROR) - return + raise except HTTPError, e: status = e.code reason = e.msg @@ -190,5 +190,6 @@ class upload(PyPIRCCommand): self.announce('Server response (%s): %s' % (status, reason), log.INFO) else: - self.announce('Upload failed (%s): %s' % (status, reason), - log.ERROR) + msg = 'Upload failed (%s): %s' % (status, reason) + self.announce(msg, log.ERROR) + raise DistutilsError(msg)""" ) )
def __patch_distutils(self): """ https://hg.python.org/cpython/rev/cf70f030a744/ https://bitbucket.org/pypa/setuptools/issues/248/exit-code-is-zero-when-upload-fails Fixed in 2.7.8: https://hg.python.org/cpython/raw-file/v2.7.8/Misc/NEWS """ if self._remote_python_version() < (2, 7, 8): with remote_sudo_popen('patch -d /usr/lib/python2.7 -p2') as patch: patch.write( heredoc(""" --- a/Lib/distutils/command/upload.py +++ b/Lib/distutils/command/upload.py @@ -10,7 +10,7 @@ import urlparse import cStringIO as StringIO from hashlib import md5 -from distutils.errors import DistutilsOptionError +from distutils.errors import DistutilsError, DistutilsOptionError from distutils.core import PyPIRCCommand from distutils.spawn import spawn from distutils import log @@ -181,7 +181,7 @@ class upload(PyPIRCCommand): self.announce(msg, log.INFO) except socket.error, e: self.announce(str(e), log.ERROR) - return + raise except HTTPError, e: status = e.code reason = e.msg @@ -190,5 +190,6 @@ class upload(PyPIRCCommand): self.announce('Server response (%s): %s' % (status, reason), log.INFO) else: - self.announce('Upload failed (%s): %s' % (status, reason), - log.ERROR) + msg = 'Upload failed (%s): %s' % (status, reason) + self.announce(msg, log.ERROR) + raise DistutilsError(msg)"""))
def __debconf_set_selections(self, debconf_selections): with remote_sudo_popen('debconf-set-selections') as f: f.write('\n'.join(debconf_selections))
def __debconf_set_selections( self, debconf_selections ): with remote_sudo_popen( 'debconf-set-selections' ) as f: f.write( '\n'.join( debconf_selections ) )