Proposal: Improve mysql_cli_version parsing to make it work with packages from mariadb package sources #568
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
The
mysql_cli_version
variable is extracted by parsing the output of{{ mysql_daemon }} --version
command.Problem
While this does work with our MariaDB v10 installation from the default package sources of Ubuntu 22.04 ...:
output:
mysql Ver 15.1 Distrib 10.6.18-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
... it is broken for a MariaDB v11 installation from the official MariaDB package sources (https://mirror.mariadb.org/repo/11.4/ubuntu/):
output:
mysql from 11.4.5-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using EditLine wrapper
The latter results in
fo
being parsed as themysql_cli_version
, leading to a failure in the next task due to the string not being able to be compared correctly during config template deployment.I am not quite sure whether this is the result of MariaDB v11 or the use of the official MariaDB package sources in order to being able to install MariaDB v11 for Ubuntu 22.04.
Solution proposal
My proposal is to use a regular expression for extraction instead of using fixed offsets.
From my understanding, MySQL outputs its version as
<Major>.<Minor>.<Bugfix>
whereas MariaDB outputs it as<Major>.<Minor>.<Bugfix>-MariaDB
.However, I was just able to confirm it working correctly for the combination of Ubuntu and MariaDB. Feel free to improve the regex if some other OS database combinations do not work as expected or if you want to further improve its resilience.