Skip to content

Issues with temporary base_directory permissions when running as root in Docker #62

Closed
@Lucas-C

Description

@Lucas-C

What action do you want to perform

Simply use pytest-mysql, but in a Docker container

What are the results

Because the user executing py.test is root, the mysqld process does not have the rights to read/write in the temporary directory created.
Specifically, this base_directory is created in factories/process.py. Because py.test tmpdir_factory relies on Python native tempfile.mkdtemp, the following extract from the doc applies:

The directory is readable, writable, and searchable only by the creating user ID.

This explains the errors I get:

E       TimeoutExpired: Executor <mirakuru.tcp.TCPExecutor: "
E                   /usr/bin/mysqld_safe --datadir=/tmp/pytest-mysql-w_4ZZi/mysqldata_31589 --pid-file=/tmp/pytest-mysql-w_4ZZi/mysql-server.31589.pid
E                   --port=31589 --socket=/tmp/pytest-mysql-w_4ZZi/mysql.31589.sock --log-error=/tmp/mysql-server.31589.log
E                   --tmpdir=/tmp/pytest-mysql-w_4ZZi --skip-syslog
E                   "> timed out after 60 seconds
/usr/lib/python2.7/site-packages/mirakuru/base.py:341: TimeoutExpired

And in /tmp/mysql-server.31589.log:

180205 16:24:10 mysqld_safe Starting mysqld daemon with databases from /tmp/pytest-mysql-w_4ZZi/mysqldata_31589
2018-02-05 16:24:10 140169925409024 [Note] /usr/libexec/mysqld (mysqld 10.1.30-MariaDB) starting as process 241 ...
2018-02-05 16:24:10 140169925409024 [ERROR] mysqld: Can't create/write to file '/tmp/pytest-mysql-w_4ZZi/mysqldata_31589/aria_log_control' (Errcode: 13 "Permission denied")
2018-02-05 16:24:10 140169925409024 [ERROR] mysqld: Got error 'Can't create file' when trying to use aria control file '/tmp/pytest-mysql-w_4ZZi/mysqldata_31589/aria_log_control'
2018-02-05 16:24:10 140169925409024 [ERROR] Plugin 'Aria' init function returned error.
2018-02-05 16:24:10 140169925409024 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
2018-02-05 16:24:10 140169925409024 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB

.

2018-02-05 16:24:10 140169925409024 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2018-02-05 16:24:10 140169925409024 [Note] InnoDB: The InnoDB memory heap is disabled
2018-02-05 16:24:10 140169925409024 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-02-05 16:24:10 140169925409024 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-02-05 16:24:10 140169925409024 [Note] InnoDB: Compressed tables use zlib 1.2.7
2018-02-05 16:24:10 140169925409024 [Note] InnoDB: Using Linux native AIO
2018-02-05 16:24:10 140169925409024 [Note] InnoDB: Using SSE crc32 instructions
2018-02-05 16:24:10 140169925409024 [ERROR] mysqld: Can't create/write to file '/tmp/pytest-mysql-w_4ZZi/ibqvuAQT' (Errcode: 13 "Permission denied")
2018-02-05 16:24:10 7f7bda9cb900  InnoDB: Error: unable to create temporary file; errno: 13
2018-02-05 16:24:10 140169925409024 [ERROR] Plugin 'InnoDB' init function returned error.
2018-02-05 16:24:10 140169925409024 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-02-05 16:24:10 140169925409024 [Note] Plugin 'FEEDBACK' is disabled.
2018-02-05 16:24:10 140169925409024 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
2018-02-05 16:24:10 140169925409024 [ERROR] Unknown/unsupported storage engine: InnoDB
2018-02-05 16:24:10 140169925409024 [ERROR] Aborting

180205 16:24:10 mysqld_safe mysqld from pid file /tmp/pytest-mysql-w_4ZZi/mysql-server.31589.pid ended

What are the expected results

No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions