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: upgrade MySQL from 5.7 to 8.1 first and then to 8.4 #1102

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Bugfix] Do not directly upgrade MySQL from v5.7 to v8.4 when upgrading from quince as MySQL does not allow that. First, upgrade to v8.1 and then to v8.4. (by @Danyal-Faheem)
This process should be automatic for most users. However, if you are running a third-party MySQL (i.e., RUN_MYSQL=false), you are expected to perform this process yourself. Please refer to the third-party provider's documentation for detailed instructions. Ensuring that your MySQL version is up-to-date is crucial for maintaining compatibility and security.
32 changes: 32 additions & 0 deletions tutor/commands/upgrade/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,38 @@ def get_mongo_upgrade_parameters(
return mongo_version, admin_command


def verify_tutor_version_for_mysql_upgrade(config: Config) -> tuple[bool, str]:
regisb marked this conversation as resolved.
Show resolved Hide resolved
"""
Checks if a MySQL upgrade is needed based on the Tutor version and MySQL setup.

This method ensures that MySQL is running and determines if the upgrade
process should proceed based on the Tutor version. It is intended for upgrades
from Tutor version 15 to version 18 or later. Manual upgrade steps are not
required for versions 16 or 17.

Returns:
tuple: A boolean indicating whether the upgrade process should proceed and
a string representing the Docker image of MySQL if applicable.
"""
if not config["RUN_MYSQL"]:
Danyal-Faheem marked this conversation as resolved.
Show resolved Hide resolved
fmt.echo_info(
"You are not running MySQL (RUN_MYSQL=false). It is your "
"responsibility to upgrade your MySQL instance to v8.4. There is "
"nothing left to do to upgrade from Olive."
)
return False, ""

new_mysql_docker_image = str(config["DOCKER_IMAGE_MYSQL"])
Danyal-Faheem marked this conversation as resolved.
Show resolved Hide resolved

if (
new_mysql_docker_image == "docker.io/mysql:8.0.33"
or new_mysql_docker_image == "docker.io/mysql:8.1.0"
):
return False, ""

return True, new_mysql_docker_image
Danyal-Faheem marked this conversation as resolved.
Show resolved Hide resolved


PALM_RENAME_ORA2_FOLDER_COMMAND = """
if stat '/openedx/data/ora2/SET-ME-PLEASE (ex. bucket-name)' 2> /dev/null; then
echo "Renaming ora2 folder..."
Expand Down
28 changes: 28 additions & 0 deletions tutor/commands/upgrade/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,34 @@ def upgrade_from_olive(context: click.Context, config: Config) -> None:
upgrade_mongodb(context, config, "4.2.17", "4.2")
upgrade_mongodb(context, config, "4.4.22", "4.4")

upgrade_to_redwood_onwards, new_mysql_docker_image = (
regisb marked this conversation as resolved.
Show resolved Hide resolved
common_upgrade.verify_tutor_version_for_mysql_upgrade(config)
)

if not upgrade_to_redwood_onwards:
return

# Revert the MySQL image first to build data dictionary on v8.1
regisb marked this conversation as resolved.
Show resolved Hide resolved
regisb marked this conversation as resolved.
Show resolved Hide resolved
old_mysql_docker_image = "docker.io/mysql:8.1.0"
click.echo(fmt.title(f"Upgrading MySQL to v{new_mysql_docker_image.split(':')[1]}"))
config["DOCKER_IMAGE_MYSQL"] = old_mysql_docker_image
# Note that the DOCKER_IMAGE_MYSQL value is never saved, because we only save the
# environment, not the configuration.
regisb marked this conversation as resolved.
Show resolved Hide resolved
tutor_env.save(context.obj.root, config)
context.invoke(compose.start, detach=True, services=["mysql"])
fmt.echo_info("Waiting for MySQL to boot...")
sleep(30)
regisb marked this conversation as resolved.
Show resolved Hide resolved

# Upgrade back to v8.4
config["DOCKER_IMAGE_MYSQL"] = new_mysql_docker_image
# Note that the DOCKER_IMAGE_MYSQL value is never saved, because we only save the
# environment, not the configuration.
tutor_env.save(context.obj.root, config)
context.invoke(compose.start, detach=True, services=["mysql"])
fmt.echo_info("Waiting for MySQL to boot...")
sleep(30)
context.invoke(compose.stop)


def upgrade_from_quince(context: click.Context, config: Config) -> None:
click.echo(fmt.title("Upgrading from Quince"))
Expand Down
18 changes: 18 additions & 0 deletions tutor/commands/upgrade/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,24 @@ def upgrade_from_olive(context: Context, config: Config) -> None:
upgrade_mongodb(config, "4.2.17", "4.2")
upgrade_mongodb(config, "4.4.22", "4.4")

upgrade_to_redwood_onwards, _ = (
common_upgrade.verify_tutor_version_for_mysql_upgrade(config)
)

if not upgrade_to_redwood_onwards:
return

message = f"""Automatic release upgrade is unsupported in Kubernetes. If you are upgrading from Olive or an earlier release to Redwood, you
should upgrade the authentication plugin of your users. To upgrade, run the following commands:

tutor k8s stop
tutor config save --set DOCKER_IMAGE_MYSQL=docker.io/mysql:8.1.0
tutor k8s start
tutor config save --unset DOCKER_IMAGE_MYSQL
tutor k8s start
"""
fmt.echo_info(message)


def upgrade_from_quince(config: Config) -> None:
click.echo(fmt.title("Upgrading from Quince"))
Expand Down
Loading