Repository: mariadb-operator/mariadb-operator

Issue:
[Bug] 0.25.0 lost+found directory not handled
When I create a new mariadb with the operator using a storage class which adds a new block device formatted and mounted with ext4 there is a lost+found directory on the filesystem root. Since the db datadir points to the filesystem root the directory shows as a database. 

```
MariaDB [(none)]> show databases;
+---------------------+
| Database            |
+---------------------+
| #mysql50#lost+found |
| information_schema  |
| mysql               |
| performance_schema  |
| sys                 |
+---------------------+
5 rows in set (0.000 sec)
```

Hints from issue comments:
@mmontes11: Hey @pasztorl ! Thanks for reporting.

Altough the MariaDB has been provisioned with the operator, I think this is more like a MariaDB issue. Could you report it here?
https://github.com/MariaDB/server@pasztorl: I've checked the mariadb documentation, and it looks like it is not an issue with the db, but they have options for that.
https://mariadb.com/docs/server/ref/mdb/system-variables/ignore_db_dirs/

Typically you can find the lost+found dir in a kubernetes volume, so I suggest that this ignore should configured by default with the operator or this custom configuration parameter can be exists by default on crd examples(?).
@mmontes11: Hey @pasztorl ! That would make sense, we could potentially create default `ConfigMap` that would contain a `0-default.cnf` config file with some default options like `ignore_db_dirs`, it should be doable.

Before doing so, we should come up with a reasonable list of directories to ignore across the most well known storage and cloud providers. I will try to come up with a list, but feedback is very welcome here.

Thanks!@pasztorl: @mmontes11 Sounds great!@github-actions: This issue is stale because it has been open 30 days with no activity.@github-actions: This issue is stale because it has been open 30 days with no activity.@mmontes11: We have added a  `ConfigMap` with default options in the last release:
- https://github.com/mariadb-operator/mariadb-operator/blob/9b4d6367cec8f4fe96ea99a808836417b0e19530/controller/mariadb_controller.go#L252

I think it would make sense to include [ignore_db_dirs](https://mariadb.com/docs/server/ref/mdb/system-variables/ignore_db_dirs/). Contributions are welcome!@github-actions: This issue is stale because it has been open 30 days with no activity.@stevefxp1: Has this been resolved bc I just did a MariaDB 10.11 install and lost+found is showing up!@mmontes11: @stevefxp1 this is not yet implemented, contributions are welcome!@github-actions: This issue is stale because it has been open 60 days with no activity.@github-actions: This issue was closed because it has been stalled for 30 days with no activity.@github-actions: This issue is stale because it has been open 60 days with no activity.@github-actions: This issue is stale because it has been open 60 days with no activity.@github-actions: This issue was closed because it has been stalled for 30 days with no activity.@github-actions: This issue is stale because it has been open 60 days with no activity.

Solution patch:
diff --git a/internal/controller/mariadb_controller.go b/internal/controller/mariadb_controller.go
index b4885e6d..40f65590 100644
--- a/internal/controller/mariadb_controller.go
+++ b/internal/controller/mariadb_controller.go
@@ -1050,6 +1050,7 @@ func defaultConfig(mariadb *mariadbv1alpha1.MariaDB) (string, error) {
 	tpl := createTpl("0-default.cnf", `[mariadb]
 skip-name-resolve
 temp-pool
+ignore_db_dir = 'lost+found'
 {{- with .TimeZone }}
 default_time_zone = {{ . }}
 {{- end }}



Test patch:
diff --git a/internal/controller/mariadb_controller_test.go b/internal/controller/mariadb_controller_test.go
index 481f771d..59d93571 100644
--- a/internal/controller/mariadb_controller_test.go
+++ b/internal/controller/mariadb_controller_test.go
@@ -65,6 +65,7 @@ var _ = Describe("MariaDB spec", func() {
 			`[mariadb]
 skip-name-resolve
 temp-pool
+ignore_db_dir = 'lost+found'
 `,
 		),
 		Entry(
@@ -77,6 +78,7 @@ temp-pool
 			`[mariadb]
 skip-name-resolve
 temp-pool
+ignore_db_dir = 'lost+found'
 default_time_zone = UTC
 `,
 		),
@@ -163,7 +165,7 @@ var _ = Describe("MariaDB", func() {
 			g.Expect(cm.ObjectMeta.Labels).To(HaveKeyWithValue("k8s.mariadb.com/test", "test"))
 			g.Expect(cm.ObjectMeta.Annotations).NotTo(BeNil())
 			g.Expect(cm.ObjectMeta.Annotations).To(HaveKeyWithValue("k8s.mariadb.com/test", "test"))
-			g.Expect(cm.Data).To(HaveKeyWithValue("0-default.cnf", "[mariadb]\nskip-name-resolve\ntemp-pool\n"))
+			g.Expect(cm.Data).To(HaveKeyWithValue("0-default.cnf", "[mariadb]\nskip-name-resolve\ntemp-pool\nignore_db_dir = 'lost+found'\n"))
 			return true
 		}, testTimeout, testInterval).Should(BeTrue())