Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MySQL Data Directory #589

Merged
merged 1 commit into from
Oct 8, 2024
Merged

Fix MySQL Data Directory #589

merged 1 commit into from
Oct 8, 2024

Conversation

tommaso-borgato
Copy link
Contributor

@tommaso-borgato tommaso-borgato commented Oct 7, 2024

Fix issues-588 by setting the correct MySQL Data Directory;

Now you can use both the following images by setting the correct datadir:

xtf.mysql.image=registry.redhat.io/rhel9/mysql-80:latest
# the following value is the default value and can be omitted
xtf.mysql.datadir=/var/lib/mysql/data

or:

xtf.mysql.image=container-registry.oracle.com/mysql/community-server:8.0
xtf.mysql.datadir=/var/lib/mysql

Please make sure your PR meets the following requirements:

  • Pull Request contains a description of the changes
  • Pull Request does not include fixes for multiple issues/topics
  • Code is formatted, imports ordered, code compiles and tests are passing
  • Code is self-descriptive and/or documented

@tommaso-borgato
Copy link
Contributor Author

tommaso-borgato commented Oct 7, 2024

CI Runs:

  • eap-8.x-openshift-4-wildfly-openjdk17/491/ run with container-registry.oracle.com/mysql/community-server:8.0
  • eap-8.x-openshift-4-wildfly-openjdk17/492/ run with registry.redhat.io/rhel9/mysql-80:1-330

@simkam
Copy link
Contributor

simkam commented Oct 7, 2024

I'm unsure about this. We might need two different implementations for RH and non-RH images. RH images are often (always?) different from community or official images. They are created for S2I and OpenShift, the other images are more generic.

@@ -6,31 +6,31 @@
public class MySQL extends AbstractSQLDatabase {

public MySQL() {
super("MYSQL", "/var/lib/mysql/data");
super("MYSQL", "/var/lib/mysql");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make it configurable through the property? Something like:

private static final String DATA_DIR_PROPERTY = "xtf.mysql.datadir";
private static final String MYSQL_DATA_DIR = System.getProperty(DATA_DIR_PROPERTY, "/var/lib/mysql/data");
...
public MySQL() {
        super("MYSQL", MYSQL_DATA_DIR);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnovak1 Tnks! that's a smart idea ... I tried and implemented it: please have a look

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with the oracle image (see eap-8.x-openshift-4-wildfly-openjdk17/502/)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also works with Red Hat image (see eap-8.x-openshift-4-wildfly-openjdk17/504/)

Copy link
Contributor Author

@tommaso-borgato tommaso-borgato Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end this PR would leave the current image setup unchanged, it would just add the option to customized the mount point for other MYSQL images:

Now you can use both images with:

xtf.mysql.image=registry.redhat.io/rhel9/mysql-80:latest
# the following value is the default value and can be omitted
xtf.mysql.datadir=/var/lib/mysql/data

or:

xtf.mysql.image=container-registry.oracle.com/mysql/community-server:8.0
xtf.mysql.datadir=/var/lib/mysql

@tommaso-borgato
Copy link
Contributor Author

tommaso-borgato commented Oct 8, 2024

I'm unsure about this. We might need two different implementations for RH and non-RH images. RH images are often (always?) different from community or official images. They are created for S2I and OpenShift, the other images are more generic.

I just checked that RH image has /var/lib/mysql/data as tdathe default a dir while oracle image has /var/lib/mysql:

container-registry.oracle.com/mysql/community-server:8.0:

sh-5.1$ cd /var/lib/mysql/
sh-5.1$ ls -la
total 97744
-rw-r-----. 1 1000900000 root   196608 Oct  7 13:14 '#ib_16384_0.dblwr'
-rw-r-----. 1 1000900000 root  8585216 Oct  7 13:11 '#ib_16384_1.dblwr'
drwxr-x---. 2 1000900000 root     4096 Oct  7 13:12 '#innodb_redo'
drwxr-x---. 2 1000900000 root      187 Oct  7 13:11 '#innodb_temp'
drwxrwx---. 1 mysql      root     4096 Oct  7 13:12  .
drwxr-xr-x. 1 root       root       38 Jul 23 06:48  ..
-rw-r-----. 1 1000900000 root       56 Oct  7 13:11  auto.cnf
-rw-r-----. 1 1000900000 root      180 Oct  7 13:11  binlog.000001
-rw-r-----. 1 1000900000 root      362 Oct  7 13:12  binlog.000002
-rw-r-----. 1 1000900000 root       32 Oct  7 13:12  binlog.index
-rw-------. 1 1000900000 root     1705 Oct  7 13:11  ca-key.pem
-rw-r--r--. 1 1000900000 root     1112 Oct  7 13:11  ca.pem
-rw-r--r--. 1 1000900000 root     1112 Oct  7 13:11  client-cert.pem
-rw-------. 1 1000900000 root     1705 Oct  7 13:11  client-key.pem
-rw-r-----. 1 1000900000 root     5623 Oct  7 13:11  ib_buffer_pool
-rw-r-----. 1 1000900000 root 12582912 Oct  7 13:12  ibdata1
-rw-r-----. 1 1000900000 root 12582912 Oct  7 13:12  ibtmp1
drwxr-x---. 2 1000900000 root      143 Oct  7 13:11  mysql
-rw-r-----. 1 1000900000 root 32505856 Oct  7 13:12  mysql.ibd
srwxrwxrwx. 1 1000900000 root        0 Oct  7 13:12  mysql.sock
-rw-------. 1 1000900000 root        2 Oct  7 13:12  mysql.sock.lock
drwxr-x---. 2 1000900000 root     8192 Oct  7 13:11  performance_schema
-rw-------. 1 1000900000 root     1705 Oct  7 13:11  private_key.pem
-rw-r--r--. 1 1000900000 root      452 Oct  7 13:11  public_key.pem
-rw-r--r--. 1 1000900000 root     1112 Oct  7 13:11  server-cert.pem
-rw-------. 1 1000900000 root     1705 Oct  7 13:11  server-key.pem
drwxr-x---. 2 1000900000 root       28 Oct  7 13:11  sys
drwxr-x---. 2 1000900000 root        6 Oct  7 13:11  test
-rw-r-----. 1 1000900000 root 16777216 Oct  7 13:14  undo_001
-rw-r-----. 1 1000900000 root 16777216 Oct  7 13:14  undo_002    

registry.redhat.io/rhel9/mysql-80:1-330:

sh-5.1$ cd /var/lib/mysql/
sh-5.1$ ls -la
total 12
drwxrwxr-x. 1 mysql      root  102 Oct  7 13:07 .
drwxr-xr-x. 1 root       root   19 Aug 28 12:56 ..
drwxrwxr-x. 1 mysql      root 4096 Oct  7 13:07 data
srwxrwxrwx. 1 1000900000 root    0 Oct  7 13:07 mysql.sock
-rw-------. 1 1000900000 root    2 Oct  7 13:07 mysql.sock.lock
srwxrwxrwx. 1 1000900000 root    0 Oct  7 13:07 mysqlx.sock
-rw-------. 1 1000900000 root    2 Oct  7 13:07 mysqlx.sock.lock

$ ls -la data
total 91600
-rw-r-----. 1 1000900000 root   196608 Oct  7 13:09 '#ib_16384_0.dblwr'
-rw-r-----. 1 1000900000 root  8585216 Oct  7 13:07 '#ib_16384_1.dblwr'
drwxr-x---. 2 1000900000 root     4096 Oct  7 13:07 '#innodb_redo'
drwxr-x---. 2 1000900000 root      187 Oct  7 13:07 '#innodb_temp'
drwxrwxr-x. 1 mysql      root     4096 Oct  7 13:07  .
drwxrwxr-x. 1 mysql      root      102 Oct  7 13:07  ..
-rw-r-----. 1 1000900000 root       56 Oct  7 13:07  auto.cnf
-rw-r-----. 1 1000900000 root     2138 Oct  7 13:07  binlog.000001
-rw-r-----. 1 1000900000 root      157 Oct  7 13:07  binlog.000002
-rw-r-----. 1 1000900000 root       32 Oct  7 13:07  binlog.index
-rw-------. 1 1000900000 root     1705 Oct  7 13:07  ca-key.pem
-rw-r--r--. 1 1000900000 root     1112 Oct  7 13:07  ca.pem
-rw-r--r--. 1 1000900000 root     1112 Oct  7 13:07  client-cert.pem
-rw-------. 1 1000900000 root     1705 Oct  7 13:07  client-key.pem
-rw-r-----. 1 1000900000 root     3739 Oct  7 13:07  ib_buffer_pool
-rw-r-----. 1 1000900000 root 12582912 Oct  7 13:07  ibdata1
-rw-r-----. 1 1000900000 root 12582912 Oct  7 13:07  ibtmp1
drwxr-x---. 2 1000900000 root      143 Oct  7 13:07  mysql
-rw-r-----. 1 1000900000 root        2 Oct  7 13:07  mysql-80-65bc4d4f46-7sdwz.pid
-rw-r-----. 1 1000900000 root 26214400 Oct  7 13:07  mysql.ibd
-rw-r--r--. 1 1000900000 root        7 Oct  7 13:07  mysql_upgrade_info
drwxr-x---. 2 1000900000 root     8192 Oct  7 13:07  performance_schema
-rw-------. 1 1000900000 root     1705 Oct  7 13:07  private_key.pem
-rw-r--r--. 1 1000900000 root      452 Oct  7 13:07  public_key.pem
-rw-r--r--. 1 1000900000 root     1112 Oct  7 13:07  server-cert.pem
-rw-------. 1 1000900000 root     1705 Oct  7 13:07  server-key.pem
drwxr-x---. 2 1000900000 root       28 Oct  7 13:07  sys
drwxr-x---. 2 1000900000 root        6 Oct  7 13:07  test
-rw-r-----. 1 1000900000 root 16777216 Oct  7 13:09  undo_001
-rw-r-----. 1 1000900000 root 16777216 Oct  7 13:09  undo_002

import cz.xtf.core.image.Image;

public class MySQL extends AbstractSQLDatabase {

public MySQL() {
super("MYSQL", "/var/lib/mysql/data");
super("MYSQL", XTFConfig.get("xtf.mysql.datadir", "/var/lib/mysql/data"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move those into the constant like:

private static final String DATA_DIR_PROPERTY = "xtf.mysql.datadir";
private static final String MYSQL_DATA_DIR = XTFConfig.get(DATA_DIR_PROPERTY, "/var/lib/mysql/data");

and use MYSQL_DATA_DIR here, please?

Copy link
Contributor Author

@tommaso-borgato tommaso-borgato Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnovak1 this way the value would be loaded all the times, not just at object creation, is that ok?

I moved the string values to constants at present, leaving retrieval in the constructor ....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnovak1 this way the value would be loaded all the times, not just at object creation, is that ok?

Actually I would resign on this and use my way :-) the problem is that you need to call XTFConfig.loadConfig() anytime you want to load updated system properties. So above will not help unless XTFConfig.loadConfig() is called before from the test code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnovak1 thank you! done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnovak1 I just verified it works with Red Hat image (see eap-8.x-openshift-4-wildfly-openjdk17/505)

Copy link
Contributor

@mnovak mnovak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mnovak mnovak merged commit 69ea28e into master Oct 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants