launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05533
[Merge] lp:~mbp/launchpad/ec2-tmpfs into lp:launchpad
Martin Pool has proposed merging lp:~mbp/launchpad/ec2-tmpfs into lp:launchpad with lp:~mwhudson/launchpad/ec2-land-instance-type-option as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~mbp/launchpad/ec2-tmpfs/+merge/82355
This tweaks a few things in the ec2 image:
* make root be data=writeback etc so perhaps faster
* put some disposable data on tmpfs
* correctly terminate instances on error! (fixes the "error 400" you may have seen)
* suppress spurious alarming "_connect: connection refused" during startup
I need to actually run a test through the result before this could be called done.
--
https://code.launchpad.net/~mbp/launchpad/ec2-tmpfs/+merge/82355
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mbp/launchpad/ec2-tmpfs into lp:launchpad.
=== modified file 'lib/devscripts/ec2test/instance.py'
--- lib/devscripts/ec2test/instance.py 2011-11-16 05:39:10 +0000
+++ lib/devscripts/ec2test/instance.py 2011-11-16 05:39:10 +0000
@@ -77,6 +77,8 @@
. /etc/lsb-release
+mount -o remount,data=writeback,commit=3600,async,relatime /
+
cat >> /etc/apt/sources.list << EOF
deb http://ppa.launchpad.net/launchpad/ubuntu $DISTRIB_CODENAME main
deb http://ppa.launchpad.net/bzr/ubuntu $DISTRIB_CODENAME main
@@ -84,6 +86,33 @@
deb-src http://us.ec2.archive.ubuntu.com/ubuntu/ $DISTRIB_CODENAME main
EOF
+export DEBIAN_FRONTEND=noninteractive
+
+echo contents of fstab before editing
+cat /etc/fstab
+# Put some io-intensive disposable directories on ramdisks; the machine is disposable
+# anyhow. These must only be things whose content is not required to persist
+# between the machine being started and it being used: so you can't put
+# /var/launchpad here because the contents are used by spawned instances.
+for d in /tmp /var/tmp /var/lib/postgresql
+do
+ [ -d $d ] || mkdir $d
+ echo "$d $d tmpfs defaults 0 0" >> /etc/fstab
+ mount $d
+done
+sed -ie 's/ext3[ \t]*defaults/data=writeback,commit=3600,async,relatime/' /etc/fstab
+echo contents of fstab after edit:
+cat /etc/fstab
+
+# Add the keys for the three PPAs added to sources.list above.
+apt-key adv --recv-keys --keyserver pool.sks-keyservers.net 2af499cb24ac5f65461405572d1ffb6c0a5174af
+apt-key adv --recv-keys --keyserver pool.sks-keyservers.net ece2800bacf028b31ee3657cd702bf6b8c6c1efd
+apt-key adv --recv-keys --keyserver pool.sks-keyservers.net cbede690576d1e4e813f6bb3ebaf723d37b19b80
+
+aptitude update
+aptitude -y install language-pack-en # Do this first so later things don't complain about locales
+aptitude -y full-upgrade
+
# This next part is cribbed from rocketfuel-setup
dev_host() {
sed -i \"s/^127.0.0.88.*$/&\ ${hostname}/\" /etc/hosts
@@ -126,15 +155,7 @@
127.0.0.99 bazaar.launchpad.dev
' >> /etc/hosts
-# Add the keys for the three PPAs added to sources.list above.
-apt-key adv --recv-keys --keyserver pool.sks-keyservers.net 2af499cb24ac5f65461405572d1ffb6c0a5174af
-apt-key adv --recv-keys --keyserver pool.sks-keyservers.net ece2800bacf028b31ee3657cd702bf6b8c6c1efd
-apt-key adv --recv-keys --keyserver pool.sks-keyservers.net cbede690576d1e4e813f6bb3ebaf723d37b19b80
-
-aptitude update
-aptitude -y full-upgrade
-
-DEBIAN_FRONTEND=noninteractive apt-get -y install launchpad-developer-dependencies apache2 apache2-mpm-worker
+apt-get -y install launchpad-developer-dependencies apache2 apache2-mpm-worker
# Create the ec2test user, give them passwordless sudo.
adduser --gecos "" --disabled-password ec2test
@@ -298,7 +319,8 @@
self._ec2test_user_has_keys = False
else:
raise BzrCommandError(
- 'failed to start: %s\n' % self._boto_instance.state)
+ 'failed to start: %s: %r\n' % (
+ self._boto_instance.state, self._boto_instance.state_reason))
def shutdown(self):
"""Shut down the instance."""
@@ -307,9 +329,10 @@
return
self._boto_instance.update()
if self._boto_instance.state not in ('shutting-down', 'terminated'):
- # terminate instance
- self._boto_instance.stop()
+ self.log("terminating %s..." % self._boto_instance)
+ self._boto_instance.terminate()
self._boto_instance.update()
+ self.log(" done\n")
self.log('instance %s\n' % (self._boto_instance.state,))
@property
@@ -322,24 +345,31 @@
"""Connect to the instance as `user`. """
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(AcceptAllPolicy())
+ self.log('ssh connect to %s: ' % self.hostname)
connect_args = {
'username': username,
'pkey': self.private_key,
'allow_agent': False,
'look_for_keys': False,
}
- for count in range(10):
+ for count in range(20):
try:
ssh.connect(self.hostname, **connect_args)
- except (socket.error, paramiko.AuthenticationException), e:
- self.log('_connect: %r\n' % (e,))
+ except (socket.error, paramiko.AuthenticationException, EOFError), e:
+ self.log('.')
+ if getattr(e, 'errno') == errno.ECONNREFUSED:
+ # Pretty normal if the machine has started but sshd isn't
+ # up yet. Don't make a fuss.
+ time.sleep(1)
+ continue
+ self.log('ssh _connect: %r\n' % (e,))
if count < 9:
time.sleep(5)
- self.log('retrying...')
else:
raise
else:
break
+ self.log(' ok!\n')
return EC2InstanceConnection(self, username, ssh)
def _upload_local_key(self, conn, remote_filename):
Follow ups