testing: touch MySQL files when starting bmoweb container
See the inline comment for rationale. So hacky.
MozReview-Commit-ID: 8NActQDyha5
--- a/testing/docker/builder-bmoweb/entrypoint.py
+++ b/testing/docker/builder-bmoweb/entrypoint.py
@@ -108,16 +108,27 @@ with open(answers, 'wb') as fh:
writeanswer(fh, 'db_user', db_user)
writeanswer(fh, 'db_pass', db_pass)
writeanswer(fh, 'db_name', db_name)
writeanswer(fh, 'ADMIN_EMAIL', admin_email)
writeanswer(fh, 'ADMIN_PASSWORD', admin_password)
writeanswer(fh, 'urlbase', bmo_url)
+# There is a weird interaction between Docker, filesystems, and MySQL where
+# a subsequent container invocation can't access MySQL data from a previous
+# one. It is suspected this has something to do with overlayfs and accessing
+# data from previous layers. This can produce failures like ``Fatal error: Can't
+# open and lock privilege tables: Table storage engine for 'db' doesn't have
+# this option``.
+#
+# We work around it by chowning everything in /var/lib/mysql, which effectively
+# copies the file to the current filesystem layer.
+subprocess.check_call(['/bin/chown', '-R', 'mysql:mysql', '/var/lib/mysql'])
+
# Start a MySQL process. mysqld_safe restarts the process when it
# terminates, so don't use that.
mysqld = subprocess.Popen([
'/usr/sbin/mysqld',
'--datadir=/var/lib/mysql',
'--user=mysql',
'--init-file=/tmp/mysql-init.sh'])
@@ -125,16 +136,17 @@ mysqld = subprocess.Popen([
# ready.
time_start = time.time()
while True:
try:
print('attempting to connect to database...')
if mysqld.poll() is not None:
print('mysqld process exited %d' % mysqld.returncode)
+ time.sleep(500)
sys.exit(1)
# There appear to be race conditions between MySQL opening the socket
# and MySQL actually responding. So we wait on a successful MySQL
# connection before continuing.
mysql.connector.connect(user=db_user, password=db_pass,
unix_socket='/dev/shm/mysqld.sock')
print('connected to MySQL database as %s' % db_user)